How do I create hit point bars for multiple bad guys?

Get help using Construct 2

Post » Sat Sep 24, 2016 12:12 pm

So, I'm kind of new. I'm creating multiple instances of bad guys who spawn in at random locations and I'm pinning their hp bars to them.

Their hp amount are instance variables. I'm just having a hard time figuring out how to id them and connect them to their prospective hp bars (that are pinned to them as they move).

I'm currently making id's (+1) for each created in the bad guy's instance variable. However, I don't think that is going to work. I need to use the UID, are those system controls only in the full version or is this impossible to do in construct 2?

A hint would be great, as I would prefer to figure it out myself, but if there is already a tutorial (that I can't find out there) that would be just as good.
B
7
S
2
Posts: 28
Reputation: 483

Post » Sat Sep 24, 2016 1:11 pm

"Containers" is one option. The other is to assign the enemy's UID to a variable on your hitbar, then you pick the hitbar by that ID when you need to adjust it.

https://www.scirra.com/manual/150/containers
ImageImageImage
B
71
S
22
G
240
Posts: 3,734
Reputation: 133,994

Post » Sat Sep 24, 2016 1:21 pm

Awesome, thanks. I think that put me on the right track.
B
7
S
2
Posts: 28
Reputation: 483

Post » Sun Sep 25, 2016 12:07 pm

Well, I'm at a loss.

For anyone wanting to help (or to check it out): www dot cazualnoob dot com /web-games

I'm having a hard time telling construct who's hp to hit.
I had the game working perfectly before I added bad guy hit points (each bad guy would take one hit to destroy, now I want 3 hits). At that time the player hp worked perfectly - sometimes it doesn't now.

Only the first bad guy has hp that is pinned - which leads me to believe my instance id's are not being successful.

I've been messing with it for so long, I'm going backwards.

I don't know when construct is selecting the target object (in javascript it would be "this"). Expressions are not my strong suit, but I can't find where in construct I can manipulate the code with expressions I want. Just having a hard time figuring construct out.

Thanks in advance.
B
7
S
2
Posts: 28
Reputation: 483

Post » Sun Sep 25, 2016 3:03 pm

I sorted it out for you and included notes in the .capx where I made the changes - https://mega.nz/#!2wkzBJAC!PwT0WTWyaJ8fIIIaFd9HyZumPJzsNgAE0dAVM2G-WUA

Good luck with your project. BTW, you can get free sound effects from here - https://www.freesound.org/browse/
B
9
S
1
Posts: 12
Reputation: 448

Post » Sun Sep 25, 2016 3:12 pm

After a quick evaluation:

1. You don't need lines 17 - 22.
2. In line 27 & 28, you mixed player health bars & text, resulting in the player's health bar getting altered when an enemy is shot.
3. In line 16, add a "Move to top of layer" for hptotalbad1 after pinning it to the turretmarker.
Image
B
18
S
6
G
1
Posts: 122
Reputation: 2,055

Post » Sun Sep 25, 2016 9:33 pm

Awesome guys, thanks for the help.
B
7
S
2
Posts: 28
Reputation: 483


Return to How do I....?

Who is online

Users browsing this forum: dop2000, KTML5, totoe and 37 guests