0 Favourites

How do I destroy only the touched sprite?

  • 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.

    https://postimg.org/image/7ilbss91x/

  • 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.

  • Construct 3

    Buy Construct 3

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

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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Sprite Font Generator - v3
368 112,324
RetroDaddy's avatar
RetroDaddy
Unread hot topic
86 28,713
St4rDu57's avatar
St4rDu57
Unread hot topic
99 10,139
karshinkoff's avatar
karshinkoff