Assign Health Bar to each Enemy?

Get help using Construct 2

Post » Mon Nov 05, 2012 5:48 pm

For each unit to have a health bar.


All I can come up with:
---------------------------------------------------------
Array
Assign Array at Enemy.UID = HP
Create Health-Bar -> Set Health-Bar Instance Variable to Enemy.UID
(The last created or should Enemy spawn the health bar?)

Each Tick.

For each Healthbar
Set "Health of Bar" to Array.Health-Bar-instance-variable.

----------------------------------------------------------

Other Suggestions?
B
40
S
11
G
4
Posts: 665
Reputation: 8,403

Post » Mon Nov 05, 2012 6:20 pm

Lets say you have a textbox which is the health bar, txtHealth. Add Pin to it (assuming, you want the health bar on the enemy)

Foreach enemy (or on enemy create), spawn the txtHealth, Pin to the enemy.

Every tick:

If txtHealth Pinned AND Enemy is overlapping txtHealth set txtHealth.Text = Enemy.Health.

If txtHealth NOT Pinned, Destroy.

Make sure the enemies don't overlap. if they do, use your own var, not UID, it changes if one enemy is removed or added.
B
41
S
8
G
6
Posts: 58
Reputation: 6,820

Post » Mon Nov 05, 2012 6:23 pm

Oh, Did not know the UID changed.

I use that because the other approach seems a bit to buggy.

Ty for the tip
B
40
S
11
G
4
Posts: 665
Reputation: 8,403


Return to How do I....?

Who is online

Users browsing this forum: Braus, shinkan and 23 guests