How do I create a life metre using sprites

Get help using Construct 2

Post » Fri Dec 12, 2014 4:20 pm

I'm currently creating a platforming game, where when the player takes a hit or falls outside the layout, 1 is subtracted from the instance variable lives, of the player, and then I call a function so that if lives = 3, set it to the full heart, 2, set it to one quarter taken away, as such:

Image

I had the code to subtract from and add to the instance variable when there's a collision with the related object (I tried having the subtract/add 1 to the lives variable within the functions themselves, but that didn't work either for me)
Similar I have a gainLives method, that on collision with a heart pick up, add 1 to the players lives, and do the same with the animation.

But the problem is, it's quite random when it decided to follow these. The player will walk into a enemy, and flash like they took damage, but the health won't change, they'll walk into the enemy again, and it'll go down by one. The same happens when picking up health. I was wondering if it would be better to use global variables instead, or if there's a different solution I don't know off (I've only found Construct recently as it's the program I need to use for an assignment).

Any help is greatly appreciated
B
3
Posts: 3
Reputation: 181

Post » Fri Dec 12, 2014 5:16 pm

,,,,,,,,,,,,,,,,,,,,,
You do not have the required permissions to view the files attached to this post.
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Fri Dec 12, 2014 7:48 pm

korbaach wrote:,,,,,,,,,,,,,,,,,,,,,


Thank you, it's fixed my issue with the death event but the health items for some reason won't increase it, even though I changed it to on collision add 1 to lives instead of calling a function...

EDIT: Nevermind! I realized I had a function for a "health" family, to enable particle effects and sound on picking up any health piece, and putting add 1 to lives there fixed my issue. Thanks (:
B
3
Posts: 3
Reputation: 181


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 3 guests