Multiple Instances of sprites/priv. variable issue

0 favourites
  • 2 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)