0 Favourites

Mouse click on object, does it cover all layers?

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

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

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • ............??????

  • ............??????

    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.

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

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

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