Prevent click/tap through opaque layer

0 favourites
  • 6 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • So guys, I have this Instructions button that makes visible a layer with some text that's placed on top of everything.

    The problem is that the user can tap through this opaque layer and activate the (now) invisible buttons (invisible because of the "instructions" layer) on the layers below.

    I don't want to create a layout with instructions because I want to keep the layout state.

    I'm looking, I think, for sort of a "handled" flag on the mouse event or something...

    Any hints?

    Thanks.

  • Instead of obscuring the objects destroy them or move them out the way, then they won't receive touch/click events. Or, set them invisible with 'Set visible' and add the condition 'Is visible' to any click/touch events.

  • Thanks Ashley - but I was hoping to avoid that (and I did, sort of). I managed to work around it by making the layout bigger and putting the instructions somewhere far off the normal viewport, and then I just scroll to the instructions, and then I scroll back to the game. This has the advantage that if I add something to the main screen, I don't have to remember to add custom stuff to it (hide it, check for visibility etc).

    So it's almost what you suggest, moving the objects away, except I didn't move the objects - I moved the thing that was supposed to be on top of them, so they don't overlap.

    However I still think that a mechanism to prevent the click or tap from "bubbling further up" (or in other words marking it as Handled) would be nice.

    Thanks!

  • If you just use the set invisible on an entire layer, you can add stuff to that layer without having to put in anymore "custom" stuff to it.

  • Actually I just did a small test. What you say applies to buttons, but not to sprites (I have sprites instead of buttons on my project).

    So if you have a sprite on an invisible layer, it will still get the "on clicked object", making it need custom stuff.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • add a boolean 'active' with default true to your sprite buttons

    +System: Every Tick
      -> Button: set active to true
    +System: Layer "yourLayer" is visible
      -> Button: set active to 'false'
    +Mouse: On left click on Button
    +Button is active
      -> System: set Layer "yourLayer" to visible
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)