Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Detecting touch direction and speed

Author
Message
pinete
12
Years of Service
User Offline
Joined: 28th Jul 2011
Location:
Posted: 16th Aug 2011 11:52
Hi,
I was wondering if there is a simple way through any function to detect the direction of user's touch and speed this movement is performed.
I mean, imagine you're going to drag a box with your finger and when you release the finger, the box is 'launched' in the direction of your finger movement and with the speed you've perfomed the movement.
Is there a easy way to do this with the current command set?
if no, could someone point me in the right direction to do it?
thanks a lot in advance!
LeeBamber
TGC Lead Developer
24
Years of Service
User Offline
Joined: 21st Jan 2000
Location: England
Posted: 16th Aug 2011 14:53
Hi, There is no command in AppGameKit to detect this, but you can do it in code quite easily by taking the difference between the last coordinate of GetPointerX/Y() and the current coordinate. Deduct one from the other and you have a direction vector (i.e. DX=NEWX-OLDX). The larger the value in DX, the faster the swipe As a bonus if you feed DX and DY into ATANFULL() and you also get the angle of the swipe!

I drink tea, and in my spare time I write software.
pinete
12
Years of Service
User Offline
Joined: 28th Jul 2011
Location:
Posted: 16th Aug 2011 15:18
Thanks so much Lee, I appreciate so much the help.

Login to post a reply

Server time is: 2024-04-19 06:54:31
Your offset time is: 2024-04-19 06:54:31