How do I seperate healthBAR to each enemy

Get help using Construct 2

Post » Fri Dec 26, 2014 12:24 pm

Hi,
I'm modifing a game based on the turret defence game template .
I want to add a health bar to each new enemy, so when an enemy is spawned I also spawn an healthBar spite and pin it to the enemy. Every time the enemy is hit I modify the healthBar width to enemy's health instance variable.
This method doesn't work as all healthBar on the screen get the same value and are destroyed when the first enemy is detroyed...
Spawning a healthBar when Spawning a new enemy
spawn1.png


Adjusting the healthBar as enemy gets hit
spawn2.png



How can I adjust the only hit enemy's healthBar?
How can I destroy the healthBar when the enemy iss dead?

TNX!!!
You do not have the required permissions to view the files attached to this post.
B
5
S
1
Posts: 31
Reputation: 431

Post » Fri Dec 26, 2014 1:29 pm

You have to work with UID and set the enemeys UID to the healtbar. For destroying the healthbar you just have to check for the UID too.
To make it right you should work with functions.

Read this:
https://www.scirra.com/tutorials/361/un ... moke-trail
https://www.scirra.com/tutorials/823/creating-function
Read this:
yeah, i really like to say that you should "Read this:"
B
12
S
5
Posts: 138
Reputation: 1,490


Return to How do I....?

Who is online

Users browsing this forum: dand, mickclarke and 26 guests