moving enemies with HP over head

For questions about using Classic.

Post » Fri Mar 26, 2010 2:50 pm

How do i add text that shows the enemy's remaining hit points over their head while they are moving(left and right).
B
14
S
2
G
2
Posts: 41
Reputation: 1,396

Post » Fri Mar 26, 2010 2:52 pm

Group them with enemies as containers, then the event:
For each enemy > place the bar over their heads (X=0, Y=-32 or something).
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Fri Mar 26, 2010 3:10 pm

Actually, a better way to do it is to not use containers. Use one text object, and create an instance for each enemy, and give the text object a private variable where you set the UID of the enemy its supposed to hover above. Then for each enemy, check if the text object's variable equals the enemy's UID and place the text object above it.

This is better than containers because this way you don't have to have a separate text object for each enemy - you only need to have a different instance of one text object.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Fri Mar 26, 2010 3:25 pm

How is that a "better" way than having them all in a nice neat group and avoiding even messing with UID?
B
2
S
2
G
4
Posts: 156
Reputation: 1,762

Post » Fri Mar 26, 2010 5:09 pm

This way it will do all the work grouping and creating text objects for each enemy automatically, and you don't have to set up containers for each one. Also, this way it reduces the number of text objects you need, and construct has a memory leak involving the number of objects in a layout (basically the more objects you have a layout, the faster it crashes when opening the expression editor - not generally an issue but when you have a lot of objects it becomes a hassle), so keeping the number of objects down will keep construct from crashing for extra time.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Fri Mar 26, 2010 6:33 pm

Thanks.
B
14
S
2
G
2
Posts: 41
Reputation: 1,396


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests