How do I dont click sprites behind sprites???

Get help using Construct 2

Post » Tue Jan 06, 2015 11:14 am

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.
block.jpg

blocks.png

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,
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 7
Reputation: 189

Post » Tue Jan 06, 2015 11:28 am

Add a "Pick top Instance" condition with the necessary part.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Tue Jan 06, 2015 12:52 pm

ty, for fast response but how and where can i do that?
B
3
Posts: 7
Reputation: 189

Post » Tue Jan 06, 2015 12:55 pm

Right click on that "On Left button clicked..." condition, pick "Add Another condition", pick "Pick top/bottom" under Z Order, pick "top"
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Tue Jan 06, 2015 1:04 pm

It dont work for me.. :cry:

blocks3.png
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 7
Reputation: 189

Post » Tue Jan 06, 2015 1:08 pm

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.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Tue Jan 06, 2015 1:08 pm

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
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Tue Jan 06, 2015 1:29 pm

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.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Tue Jan 06, 2015 1:52 pm

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
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Tue Jan 06, 2015 1:59 pm

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
Last edited by Remus B on Tue Jan 06, 2015 2:03 pm, edited 1 time in total.
B
18
S
4
Posts: 87
Reputation: 1,199

Next

Return to How do I....?

Who is online

Users browsing this forum: Elliott and 2 guests