How do I destroy sprites pinned to a place holder?

0 favourites
  • 5 posts
From the Asset Store
Forgotten Place - Melodic ambiance, background music, Synth
  • I have a spawner instance that spawns an enemy_1 placeholder every x seconds which in turns spawns an enemyOneAnimation. Please see link http://i.imgur.com/xdxuyoc.png

    I tried destroying the enemy_1 placeholder that hold the animations like this: http://i.imgur.com/HXiBaVI.png

    The problem I've encountered is when I destroy the enemy_1 placeholder, it destroys the entire spawned group and not just the one that collided with the player box sprite.

    Basically, what I want to happen is when the player box collides with enemy_1, I want to destroy just the enemy_1 and enemyAnimation it collided with NOT the entire goup. I looked into using UIDs but I can't figure it out how to us them. Can someone help me with this? Thank you.

  • Easiest solution would be to add them to the same container—when one item in a container is destroyed all are destroyed.

    But you should also try to understand better how instances are picked, it will help you in the long run.

    if you do when player collides with enemy_1 then the player instance and enemy_1 instance will be picked. But you have not picked any enemyAnimations instances yet so all are picked. So if you destroy enemyAnimation then all of them will be destroyed.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • make variable Boolean true and when player collided with enemy_1 set is false

    when enemy is false - destroy

  • thanks for your suggestion. I'll definitely look into this. Do you know any tutorials/resource about it? If not, I'll search for it. Thank you.

    CBelle thanks! I used variable number variable isHit before but still didn't work. I'll try your suggestion.

  • You can take a look at this:

    https://www.scirra.com/manual/150/containers

    It is easy to setup—just click on an object and look for the container property in the property bar.

    Don't have a lot of experience with them but most importantly: (from the manual)

    Placing objects in a container has the following effects:

    If one object in a container is created, every other object in its container is also automatically created.

    If one object in a container is destroyed, every other associated object in its container is also destroyed.

    If a condition picks one object in a container, every other associated object in its container is also picked.

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