How do I destroy only the touched sprite?

0 favourites
  • 3 posts
From the Asset Store
Minimal Sprite Font with Stroke for Pixel Art games.
  • 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.

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

  • Try Construct 3

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

    Try 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)