How do I Pick one sprite

Get help using Construct 2

Post » Thu Jul 02, 2015 4:56 pm

so if I have two sprites with a health variable and a healthbar and one of them dies how can I make the healthbar of the one that died disappear without also deleting the healthbar of the sprite that's still alive?
B
22
S
8
Posts: 203
Reputation: 2,059

Post » Thu Jul 02, 2015 5:40 pm

You could put the health bar in the container of the sprite - this way it would get destroyed if the object, that's containing it gets destroyed.

Other than that it can also simply solved by linking the health bar to the sprite by simply using instance variables and simply selecting accordingly.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Thu Jul 02, 2015 7:07 pm

Well I'm using a progress bar for it and I tried
Sprite.health is less than or equal to 0: Sprite destroy
: Health bar destroy
but that destroys all the health bars

I also tried setting the health of the bar to the health of the sprite and destroy the bar when it's health is zero but that doesn't work either
B
22
S
8
Posts: 203
Reputation: 2,059

Post » Thu Jul 02, 2015 7:22 pm

maybe it isn't working if you destroy the sprite before destroying the progressbar(it won't be able to reference the sprite's health thus it won't be set to 0).
You also have to make sure you are picking the correct instance.
B
41
S
19
G
65
Posts: 1,085
Reputation: 37,842

Post » Thu Jul 02, 2015 8:47 pm

Hmmm I'll try rearranging the order that they're destroyed and see if that works :)
B
22
S
8
Posts: 203
Reputation: 2,059


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 14 guests