Save touch coordinates to variable

Get help using Construct 2

Post » Fri Sep 14, 2012 7:19 pm

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.
B
33
S
12
G
7
Posts: 227
Reputation: 7,582

Post » Sat Sep 15, 2012 2:33 am

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. kittiewan2012-09-15 02:36:50
B
29
S
11
G
12
Posts: 281
Reputation: 11,878

Post » Sat Sep 15, 2012 9:48 am

Than I guess I didn't understand how local variables work.

Thanks for your help.
B
33
S
12
G
7
Posts: 227
Reputation: 7,582


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Artpunk, Bad Wolf, indiegrimes, NRABrazil, WhosWho and 29 guests