Save touch coordinates to variable

0 favourites
  • 3 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • How do I save the initial touch coordinates on start of the touch to a variable.

    Using on touch start gives back a 0.

    Same happened when I used the wait action, after wait ended the coordinates went back to 0.

  • Here's an example that shows coordinates at start and end, with . . . while in touch.

    TouchPosition.capx

    One thing to check is that you have Use mouse input set to Yes if you are using touch on a computer where you have a mouse rather than touch device. Forget to do this and it will seem like on touch start isn't working, mostly because...it isn't!

    PS. One other thing you should check is the type of variable you are using. In this example I used global variables. But if you are using a local variable, it could be you have a "scope" problem. Local variables are only visible inside the construct where they are created. So if you create a local variable inside a loop, it is only available inside that loop, and it gets reset back to its initial value (default 0) each time the loop starts.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Than I guess I didn't understand how local variables work.

    Thanks for your help.

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