How to detect two different thumb touch and perform actions accordingly?

0 favourites
  • 7 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • Hi Friends, I need help in detecting two different thumb touch.I don't know how to use touch.id to do it. Any capx help will be deeply appreciated.

    What I am trying to do?

    1. When user is touching screen with left thumb, player is running

    2. When player is already running and user touch/swipe up screen with right thumb, player jumps.

    I have already seen touch detect tutorial but couldn't understand it. My bad I just beginner type for construct 2

    Please help me or suggest me ways to detect two different thumb touch at same time on mobile screen.

    Thanks a lot guys in advance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There are several ways to do this.

    You can keep track of Touch IDs - check when each one starts and ends, but this is probably the hardest method.

    You can use "Nth touch" events and expressions Touch.***At(). For example if two fingers are touching the screen, Touch.XAt(0) will return X for the first touch and Touch.XAt(1) for the second.

    And finally, you can place two big invisible sprites, one on the left side of the screen and one on the right. And then simply check "Is touching object LeftSprite -> Run", "Is touching object RightSprite -> Jump".

  • Thanks Dop for the suggestion. But the thing is left hand thumb or finger touch is used as player movement/action and right thumb swipe up anywhere on screen makes player jump. You can check this sample game at playstore play.google.com/store/apps/details

    player can shoot and jump at same time.

    How can we do that ? Please guide me.

  • Your game is in landscape, so it's very unlikely that player will touch the left side of the screen with the right thumb. So if the left side of the screen is touched, you do movement/action, and when the right side of the screen is touched, you make the player jump.

    You can do this:

  • Hi Dop, thanks for the time and example. But for me the issue still exist. The thing is two touch should be active at same time. like one touch controlling movement of the player and other touch on same time at screen (may be on jump or fire button) do its action.

    how can i detect that when user is touching button 1 on screen, he is trying to move player at the same time while player is moving and button 2 is touched, is trying to fire or jump along with movement.

    Can you help me out? and I really appreciate for sharing with precious time in helping me.

  • Please read the official manual, there are lots of expressions that you can use to work with multiple touches. For example, Touch.TouchCount will give you the number of active touches. So if you require two touches to do some action, you can check that Touch.TouchCount=2

    .

    If you are planning to have on-screen buttons to Fire and Jump, this makes everything much easier. You can put a big invisible sprite on the left side of the screen, which will be your RunButton, and then just add these events in your code:

    Touch is touching RunButton -> run
    Touch is touching JumpButton -> jump
    Touch is touching AttackButton -> fire
    ...
    
  • Hi Dop,

    Thanks for the time. Problem with touch count is on second touch on the device it turns all touch to count 2 making it difficult to detect which finger touch made it count 2, was it first touch or 2nd touch.

    Quite difficult to explain but really grateful to you to suggest me solution and some point it has helped me :)

    Regards,

    Jatin

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