How to catch touch event on part of screen

  • Hi everyone,

    I want to do 2 different actions when users touch to the screen. In fact, if users touch to the top-half, it will do something while when they touch to the second-half which is the bottom-half of the screen, it will do something else.

    The current solution that I used is that I have to objects on screen and set its opacity to 0. The first object covers the top-half of the screen while the second object covers the bottom-half. In this case, I just catch the event 'on touch' for each object. Unfortunately, it makes the game a little bit slow.

    Is there any other method I can use?

    Thanks in advance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That sounds like an efficient way of doing it, as an invisible object doesn't really do anything to performance.

    The in-game lag is likely due to something else, not the touch input.

  • Another method you could use is:

    on touch

    system compare two values: touch.y < windowheight/2 - action for top half

    on touch

    system compare two values: touch.y > windowheight/2 - action for bottom half

  • Another method you could use is:

    on touch

    system compare two values: touch.y < windowheight/2 - action for top half

    on touch

    system compare two values: touch.y > windowheight/2 - action for bottom half

    Thanks LittleStain. That was the method I was looking for. In this situation I do not need those invisible blocks to catch the touch event.

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