Multiple Instances of sprites/priv. variable issue

Get help using Construct 2

Post » Sun Oct 21, 2012 8:12 pm

Hey Guys,

I have an enemy sprite, set to invisible and the actual animated sprite set to the x,y location of the invisible one. I have no issues with the individual movements if there are more than one of these enemies on the screen. The problem is the animations and hit points.

Each enemy has hp and will flash when hit. If one of these enemies dies, the rest stop flashing when hit. The same goes for animation in general. The Variables are attached to the controlling invisible sprite.

I think I'm screwing up my "For Each" and SpriteX Parent= SpriteY crap. I have all actions set to the controlling sprite. The animation sprite is only for show.

For example, when the enemy is getting hit I have:

[Bullet group] On collision with [WolfControlSprite]
[WolfControleSprite] Hit=0
[WolfSprite] parent = [WolfControlSprite.UID]
               [BulletGroup] Destroy
               [WolfSprite] Flash:Flash0.1 on 0.1off for 1 seconds
               [WolfControlSprite] Set Hit to 1
               [System] Wait 1.0 seconds
               [WolfControlSprite] Subtract 1 from HP
               [WolfControlSprite] Set Hit to 0

I realize I can use <>[WolfSprite] Flash here but I like to use variables in these situations.

The problem here is that it can randomly subtract the hp from another sprite instance. If I use "For Each" here it really messes things up.

Thanks for any help in advance!


Chris


B
45
S
12
G
7
Posts: 339
Reputation: 7,899

Post » Sun Oct 21, 2012 11:18 pm

Nevermind - solved my own problem. When destroying the parent sprite, the child sprite latched to the next parent sprite instead of being destroyed with the parent. For some reason I thought The child was destroyed with the parent. My bad :)

The child wasn't reacting to any of the code related to the parent once it was destroyed and was sitting on top of the new child, but the new child wasn't reacting either...

Regardless I added [WolfSprite] destroy and everything is good. Now to give it an attack routine.
B
45
S
12
G
7
Posts: 339
Reputation: 7,899


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 12 guests

cron