Prevent layer from interaction

  • I have some kind of book pages which are represented as layers in Construct. On every page are different characters. All characters are dragable.

    By switching pages, I activate and deactivate layers and so I can browse through the book and look at the characters. But trying to drag them leads to errors cause is seems that a deactivated layer or object receive events too.

    I there any way to prevent them from getting the click/drag event? I can't find any option to deactivate the layer or the object.

    Further I can't see something like groups to make it easier to control on a single layer. Any suggestions?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can't prevent the clicks from coming through. But you can add a filter to your events. For example, if you deactivate layers by making them invisible, you can add this condition to all "On clicked" events:

    Is Layer Object.layerNumber visible

  • you can also use families to make groups, give the family an instance variable to associate them with a page to help with filtering.

  • Thanks for your replies.

    As far as I have tested, filtering isn't working in this case cause it seems that the upper layer "blocks" the events for the other objects below.

    So, objects below this invisible upper layer seems not to receive my drag event. Or am I filtering wrong?

    Here I filter for visibility of the layer, the object and in addition if the object is on the right layer, but still I can only drag the objects on the top layer. Moving the objects away a little bit, I'm able to drag the objects below them.

  • Touch and Mouse events like "On object clicked" are picking all instances on all layers under the cursor or finger, but Drag & Drop behavior works differently. It picks the top instance only, even if this object is invisible, or the layer is invisible.

    So if you need to prevent objects from dragging on a particular layer, you need to disable Drag & Drop behavior for them.

  • Thank you, that's the hint I've been looking for!

    In my case, disabling the Drag & Drop behavior for objects on hidden layers seems to solve the problem.

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