Mouse click - Superimposed sprites

Get help using Construct 2

Post » Sun Jul 22, 2012 1:31 pm

i have 2 sprites superimposed on each other.
the sprite on the "bottom" protrudes half way from the "top" sprite

is there a way that if i mouse click on the top sprite, I only trigger an event on the top sprite and not on the bottom sprite too?

thanks
B
41
S
11
G
4
Posts: 428
Reputation: 7,356

Post » Sun Jul 22, 2012 1:43 pm

Is it two instances of the same sprite?

Mouse: On Left button Clicked on Sprite
Sprite: Pick top instance
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Sun Jul 22, 2012 1:46 pm

no they are 2 totally different sprites.
in some occasions I can have 3 sprites on top of each other too.
B
41
S
11
G
4
Posts: 428
Reputation: 7,356

Post » Sun Jul 22, 2012 1:54 pm

i think i need some way so that when the first mouse click event is triggered, C2 stops checking the other mouse events underneat.

like and if..else condition structure
B
41
S
11
G
4
Posts: 428
Reputation: 7,356

Post » Sun Jul 22, 2012 2:32 pm

That's not possible, all clicks run simultaneous.
What you need is separate events for when objects are overlapping.
What that order is will determine how you set that up.

If you don't really care what is clicked when they are over lapping, then you can just make a generic event that covers everything.newt2012-07-22 14:37:02
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » Sun Jul 22, 2012 2:49 pm

You could put all the sprites in a family and do what I said above:

Mouse: On Left button Clicked on Family
Family: Pick top instance
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Sun Jul 22, 2012 6:37 pm

I like the idea.
I have set up a family with 4 sprites to test but cannot find the Pick Top Instance Action :(
B
41
S
11
G
4
Posts: 428
Reputation: 7,356

Post » Sun Jul 22, 2012 6:43 pm

It's at the bottom of the sprite/family's action list, under "Z order".
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Sun Jul 22, 2012 7:50 pm

thanks found the option.

works, but the action is always processed on the top most sprite of the family, even if i click on the bottom sprite and don't touch the top one :(
B
41
S
11
G
4
Posts: 428
Reputation: 7,356

Post » Sun Jul 22, 2012 8:37 pm

How about if you add a counter that registers how many objects are clicked, and only do the "Pick top" action if there's more than 1?
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Next

Return to How do I....?

Who is online

Users browsing this forum: badmoodtaylor, Yahoo [Bot] and 12 guests