Mouse click on object, does it cover all layers?

Get help using Construct 2

Post » Sat Dec 06, 2014 10:28 pm

Hi.

Is it correct that the mouseclick on object is for all layers?

I have a background layer, and a game layer which is on top of the background layer, and an event that acts if the click is on a sprite, and another event if the click is over the background.

But when I click a sprite, it seams that the background counts as a click as well.

So is it correct that the click is actually covering all layers and not only the first object on the top layer?
B
5
S
1
Posts: 59
Reputation: 493

Post » Sat Dec 06, 2014 11:26 pm

On mouse click c2 detect the object that is on top in the Z order. So if its not working, try to send it to the top of all objects that u have on that location.

Example:

Layer 1
Obj1
Obj2

Layer 2
Obj3
Obj4

Layer 3 (Background)
Obj5
Obj6

If the object 1 and 3 is on top of each other, your click will get the object 1. If they are not, obviously you will be able to click on both.
Last edited by kossglobal on Sat Dec 06, 2014 11:32 pm, edited 1 time in total.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612

Post » Sat Dec 06, 2014 11:31 pm

............??????
You do not have the required permissions to view the files attached to this post.
B
66
S
24
G
7
Posts: 1,514
Reputation: 11,039

Post » Sat Dec 06, 2014 11:41 pm

korbaach wrote:............??????


Thanks korbaach

Your project illustrates that it is true. The click on event is fired for the red sprite even though the blue sprite is covering it completely.

So I was right about that Construct 2 does not take the z order of the layers into consideration.
B
5
S
1
Posts: 59
Reputation: 493

Post » Sat Dec 06, 2014 11:43 pm

kossglobal wrote:On mouse click c2 detect the object that is on top in the Z order. So if its not working, try to send it to the top of all objects that u have on that location.

Example:

Layer 1
Obj1
Obj2

Layer 2
Obj3
Obj4

Layer 3 (Background)
Obj5
Obj6

If the object 1 and 3 is on top of each other, your click will get the object 1. If they are not, obviously you will be able to click on both.


Not true kossglobal.

See the example file above, it tells me that the z order is not important and a single left click is firering through all sprites below the mouse cursor.
B
5
S
1
Posts: 59
Reputation: 493

Post » Sat Dec 06, 2014 11:47 pm

hgr wrote:
kossglobal wrote:On mouse click c2 detect the object that is on top in the Z order. So if its not working, try to send it to the top of all objects that u have on that location.

Example:

Layer 1
Obj1
Obj2

Layer 2
Obj3
Obj4

Layer 3 (Background)
Obj5
Obj6

If the object 1 and 3 is on top of each other, your click will get the object 1. If they are not, obviously you will be able to click on both.


Not true kossglobal.

See the example file above, it tells me that the z order is not important and a single left click is firering through all sprites below the mouse cursor.


Sorry, you are right. Well, I think you can get the UID of all objects that you got on that click and filter which one is to do the action you desire.
B
56
S
21
G
3
Posts: 602
Reputation: 6,612


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests