How do I destroy only the touched sprite?

Get help using Construct 2

Post » Sun Apr 10, 2016 1:52 pm

Hello World,

As you can see in the event below I have a bunch of monsters on the screen, when I click on one of them I create a sprite called "SelectedRectangle" on top of the monster I just touched(it's transparent in the middle with just the edges that go around the monster) to show that that monster has been selected.
If however I click again on a monster that has already been selected I want only the SelectedRectangle of that monster to be destroyed. The way I have it set up right now all the rectangles get destroyed.:(

I tried messing around with families and the different pick conditions, but I can't get it to work properly.
Can you please show me how to modify that event(without breaking the other things it does) so that when I tap on a monster that has already been selected only it's rectangle will get destroyed?

Thank you.

Image
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Sun Apr 10, 2016 4:23 pm

You haven't picked the Sprite to destroy though, so the default is that all are picked, and so all get destroyed. You could try picking the Sprite that overlaps AllMonsters, or store the UID of the Sprite when you create it, and pick the Sprite when you need to destroy.
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Sun Apr 10, 2016 4:57 pm

blackhornet wrote:You haven't picked the Sprite to destroy though, so the default is that all are picked, and so all get destroyed. You could try picking the Sprite that overlaps AllMonsters, or store the UID of the Sprite when you create it, and pick the Sprite when you need to destroy.


@blackhornet is right.
You can pass or save the UID of the touched object (object.UID). You can later use "Pick instance by UID".

Hopes this helps.

Regards
Andy
Image Image iTunes: Match3 | Google Play: Match3
B
98
S
33
G
30
Posts: 1,124
Reputation: 27,805


Return to How do I....?

Who is online

Users browsing this forum: AndreasR, tarek2 and 12 guests