How do I destroy sprites pinned to a place holder?

Get help using Construct 2

Post » Fri Aug 05, 2016 1:41 am

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.
B
28
S
11
G
15
Posts: 47
Reputation: 9,533

Post » Fri Aug 05, 2016 4:37 am

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.
ImageImageImage
B
39
S
22
G
11
Posts: 486
Reputation: 9,913

Post » Fri Aug 05, 2016 4:38 am

make variable Boolean true and when player collided with enemy_1 set is false
when enemy is false - destroy
B
15
S
7
G
7
Posts: 201
Reputation: 5,277

Post » Fri Aug 05, 2016 12:38 pm

@badmoodtaylor 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.
B
28
S
11
G
15
Posts: 47
Reputation: 9,533

Post » Fri Aug 05, 2016 2:10 pm

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.
ImageImageImage
B
39
S
22
G
11
Posts: 486
Reputation: 9,913


Return to How do I....?

Who is online

Users browsing this forum: jaytrott86 and 8 guests