Why is touch propagating to other objects and how to prevent this?

  • While I love Construct's workflow there is one issue with the touch handling that has came up in every single of my projects for years.

    The lack of a setting for not letting touch/click through to the underlying objects.

    Example: You display a dialog box on top of the game; now clicking anything in it will also trigger random touch events below. Same with menu bars, pause screens etc..

    Actually it's kind of hard to find use cases where it would be the desired behavior for touches/clicks to leak all the way across everything on the Z axis.

    It would be way more convenient to just slap a "stop touch" tickbox on a button rather than go around juggling variables and conditions to prevent said issue from happening.

    Since a lot of games contain popup boxes etc. I'm starting to think maybe I'm missing something or maybe there is a go-to obvious workaround (other than "manually" disabling touch handlers by means of variables/conditions etc)?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I usually do this is with event groups. Say, I have "Controls Game" group (active) and "Controls Dialog" group (deactivated). When I need to display a dialog, I deactivate "Controls Game" group and activate "Controls Dialog".

    There are other methods of course. For example, if you have lots of different controls on different layers, you can add them all into a family AllButtons, and create instance variable FunctionName. When AllButtons is touched, pick the instance which is on the highest visible layer and has the highest z-index. Then call the function from FunctionName variable.

  • Actually clever approach; with the FunctionName. I'll try it out.

    Adding groups or control variables and enabling/disabling is more or less what I do; still none of the hoop jumping would be necessary if objects just didn't let touch/mouse through, especially because in 99% cases this is the intended behavior.

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