Anyone know the events for health hearts?

0 favourites
  • 9 posts
From the Asset Store
Custom animated Health Bar - check youtube video to make it yourself
  • Hi, I've been trying for about 7 hours to make this work. I have 3 player hearts, ๐Ÿ’“ ๐Ÿ’“ ๐Ÿ’“, when the player gets shot, I want one heart to go away then he dies after 3 shots.

    I have an instance variable set to life 3.

    I set the animation to self.playerlife+1.

    Set subtract 1 from life.

    I have played about with loads of combinations, but I'm at wits end

    Please help, thanks

  • It would be easier if you provide a capx

  • Hi, Thanks for the reply. I did it! I m a bit confused because it seems a bit two simple but it seems to work, the hearts go down one by one when shot! After so much time looking at on call functions, global variables, it seems to work.

    [img=

    ]

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Also you dont need to set the hearts animation every tick, this sort of thing will eat your performance.

    you only need to do it when the life changes.

    move the set animation to under the collision events and delete the every tick.

  • I would check that the animation speed is set to 0.

    Maybe you left it at default so no matter what it keeps playing always ending on frame 3

  • Maybe you can try this logic :

    Prepare :

    Global Variabel Life = 3

    Sprite Heart with Frame (Frame 0 = 0 heart, Frame 1 = 1 Heart, Frame 2 = 2 heart, Frame 3 = 3 heart)

    Animation Speed = 0, Animation Loop = No

    When something cause Life decreased : Subtract Life

    Set animation frame sprite Heart => Frame number = Life

  • OP said they changed the animation, not the animation frame, that might or might not be a problem. Further screenshots required

  • OP said they changed the animation, not the animation frame, that might or might not be a problem. Further screenshots required

    Pardon me, what is "OP" word mean ?

    IMHO :

    Change the "animation" or "animation frame" depends on your need and your sprite design

    If you put it separately in different animation, then you should change animation (make the animation name is contain number, more easy to defined the variabel value of "life" or "heart"

    If you only use 1 animation, but contain more than 1 frame, then you should change animation frame

    Well there is a lot of method to do this..

    you even can use separate sprite (destroy and create object on (X,y) or hide the sprite visibility)

    All depends on your game design needs and your goal.. as long as prevent to use uneccesary alorigthm which need too much resources like "Every tick" cause the system counting every time...

    Just my humble opinion :)

  • Hi thanks everyone. What I have learnt is that their are multiple ways of working. So it's quite interesting and helpful getting your thoughts and help. Thanks everyone. The animations seem to be working for now. :-).

    I agree, I am trying to keep "everything to a minimal (couple of times in a layout

    )

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)