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
Adjusting the healthBar as enemy gets hit
How can I adjust the only hit enemy's healthBar?
How can I destroy the healthBar when the enemy iss dead?
Develop games in your browser. Powerful, performant & highly capable.
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.
https://www.scirra.com/tutorials/361/un ... moke-trail