Touch.Angle

Discussion and feedback on Construct 2

Post » Sat Nov 23, 2013 11:18 am

Hi

I used the Touch.AngleForID() expression and it doesn't generated useful values all the time, as described in the manual: "A touch must be moving across the device screen for this expression to contain a useful value."

So I decided to build my own Touch.Angle expression and was amazed (thanks to the math.angle() expression) how easy it was.

You just have to get the starting & ending Touchs X and Y and put it in math.angle() like this:
angle(TouchStartX, TouchStartY, TouchEndX, TouchEndY) and you'll always get a correct and useful angle for your touch.

And finally here's a little example (you can even use mouse to test):
https://dl.dropboxusercontent.com/u/61284640/TouchAngle.capx

Hope this helps somebody.
B
20
S
3
G
2
Posts: 34
Reputation: 2,675

Post » Sat Nov 23, 2013 2:00 pm

Just a heads up that what you've made is functionally different from the Touch angle expression. The touch angle updates in real-time based on the current direction of the touch - so if you swipe in an L shape, you'll get the correct touch angle towards the end of the swipe, whereas this method just tell you the angle from the start to the end.
Scirra Founder
B
387
S
230
G
87
Posts: 24,248
Reputation: 192,238

Post » Sat Nov 23, 2013 3:42 pm

Oh ok, I didn't know that but I thought that there's something more behind your Touch.Angle...

But it might be useful to sometimes just have the whole touch angle as one "correct" value and so this will probably help some people. Geru2013-11-23 15:43:11
B
20
S
3
G
2
Posts: 34
Reputation: 2,675


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 4 guests