How do I view and manage the lifes/hearts of a player

Get help using Construct 2

Post » Mon Aug 04, 2014 8:40 pm

Right now I simply have 5 sprites anchored on the players layer. But how can I remove one heart when the player dies? How do I know which one to remove? I know I could select by UID, but what if I want to have different amounts of starting lifes?

Any help would be greatly appreciated ;)
B
4
Posts: 5
Reputation: 202

Post » Mon Aug 04, 2014 9:41 pm

There's different ways to go about it, the one i usually use a single sprite with different frames for the amount of hearts. First frame (which is frame 0) has no heart, frame 1 has 1 heart, etc. I set the animation speed to 0 then i set the frame to match my player's life variable.
B
11
S
2
Posts: 100
Reputation: 1,150

Post » Mon Aug 04, 2014 9:55 pm

This sadly limits the maximum amounts of hearts I can have to the size of my sprite :/
If at all possible I would like the lifes of the character to only be limited by the width of the screen (or a limitation I can set however I want).

But for the time being, a sprite with multiple frames seems a good idea :)
B
4
Posts: 5
Reputation: 202

Post » Tue Aug 05, 2014 2:19 am

Why don't you just use a tiled background and set it's width according to the number of lives that you have
https://www.scirra.com/manual/118/tiled-background
What I know would fill a Book , what I don't know would fill a Library
B
37
S
12
G
29
Posts: 331
Reputation: 16,499

Post » Tue Aug 05, 2014 2:50 am

Not sure what you mean by this
Terces wrote:This sadly limits the maximum amounts of hearts I can have to the size of my sprite :/


This tutorial shows the method described by @kraed

https://www.scirra.com/tutorials/565/be ... -indicator

Another idea is to stay with your original method, but to answer the question
Terces wrote:But how can I remove one heart when the player dies? How do I know which one to remove?

you can do:

Event
System: Pick sprite instance sprite.Count - 1

Action
sprite: Destroy

Assuming they are displayed in the order they were created in (might need to re-order them first).
You do not have the required permissions to view the files attached to this post.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, dop2000 and 37 guests