How do I dont click sprites behind sprites???

0 favourites
  • 15 posts
From the Asset Store
Click! Click! 136 click sounds for your video games or media projects
  • Hello,

    I cant find a solution on this Forum so fast...

    I have a Mouse click a object and after it gets clicked it gets destroyed. But when I have 2 objects behind each other. And you clicked on the one of the front it wil destroy both with 1 mouse click.

    for example:

    We got a Green square and a Yellow square.

    [attachment=1:1x5d0s7e][/attachment:1x5d0s7e]

    [attachment=0:1x5d0s7e][/attachment:1x5d0s7e]

    But when I click the Green block they both got destroyed in 1 click! How is this possible I clicked the green one and not the yellow one.. ??

    If someone can learn me the trick of this, I can solve alot of problems from my game. Ty,

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Add a "Pick top Instance" condition with the necessary part.

  • ty, for fast response but how and where can i do that?

  • Right click on that "On Left button clicked..." condition, pick "Add Another condition", pick "Pick top/bottom" under Z Order, pick "top"

  • It dont work for me..

    [attachment=0:1rgbq5rz][/attachment:1rgbq5rz]

  • Ok, then add the "Pick top instance" as subcondition - Right click on the top line and pick "Add ==> Add sub event" and place it there. That oughta work.

  • Won't work because they are 2 different object types. You could add a local non-static variable 'destroyed' or similar, and set it to 1 if you destroy the yellow block, then don't destroy the green if it = 1

  • Ah, right, two different types of blocks... my bad. The variable approach mentioned by codah sounds very sensible. You can add a subcondition in place of the "Pick top instance" of, say "Destroyed < 1" and do a Destroyed Add 1 and that should work.

  • Was just a first thought, but perhaps a Family would be better, with the block types in it, then just pick instance with index 0, or something like that

  • You can still use "pick top" condition from the z order while using a family.

    So no need for any complications, make a family with both objects in it and than set the code for that:

    ->on touched object "family1" and family1|pick top --> family1 | destroy

  • You can still use "pick top" condition from the z order while using a family.

    sounds good

  • Mmmh, very annoying, i dont get it so i need to give al my objects a variable... i can use a family for al my sprites but still if i click one object the object behind also get hit by that mouseclick.. i tought maybe i missed a feature in construct.. I make a Hidden object game so there are alot of objects ^^

  • Try this cap.x!

  • Oke Thanks, Now I need to put everthing in a family.. weird that it works like this.. Thank you ^^

  • Np, glad it worked out.

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