unique sprites?

Get help using Construct 2

Post » Mon Jan 20, 2014 8:58 am

A while ago I tried making a game where it spawned 3 sprites (enemies) which was of the same sprite, just 3 copies. When I shot one of them, a health bar would appear beneath them. But when I did shoot them, the health bar appeared below all of the enemies. As if that wasn't enough problem, the health-bar was changing on ALL of the bars, even though you just shot one of the enemies.

I was thinking if there is a way to make a sprite unique or something? Because that might fix it, right? Or is there another way to do fix so not all change?
Website Twitter Indie Developer
B
20
S
6
G
4
Posts: 206
Reputation: 2,954

Post » Mon Jan 20, 2014 9:11 am

It would help a lot if you'd give the example capx ..

Where you store the enemy health? Is it a instance variable or global variable?
Need help? Upload .capx file with your question.
B
16
S
4
G
2
Posts: 233
Reputation: 2,560

Post » Mon Jan 20, 2014 10:24 am

http://i43.tinypic.com/11cftp2.png here's how the eventsheet looks like.
I use instance variables on the enemies
Website Twitter Indie Developer
B
20
S
6
G
4
Posts: 206
Reputation: 2,954

Post » Mon Jan 20, 2014 11:10 am

just create a "for each enemy" event and put all the events but the bullet on collision as subevents.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jan 20, 2014 11:25 am

You'd also need a way to tell C2 which healthbar you'd want to affect.
Easiest way would be to give the healthbar an instance variable uid and set it to the uid of the enemy.

so add an action to the healthbar create event.
healthbar set variable uid : enemy.uid

and add this condition to the enemy variable check events:

healthbar compare variable uid = enemy.uid
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jan 20, 2014 12:28 pm

As an efficiency point.. You don't need to check/set the health bar on each tick, just set it once after the bullet have been hit and health is lowered. Joannak2014-01-20 12:28:54
Need help? Upload .capx file with your question.
B
16
S
4
G
2
Posts: 233
Reputation: 2,560


Return to How do I....?

Who is online

Users browsing this forum: AkbarAsgharMG, matriax, vargazso and 23 guests