First of all, I'd like to say thanks to 'Daniel TGC', who posted a few years ago some code that uses standard AppGameKit functions to detect what direction a user swiped.
This has been taken a little further. As you know, there is not standard commands to check for swipe, you have to code it. A friend of mine from
http://www.puddleduckappware.co.uk has refined Daniel's code more, making it less, quicker and also checking for multi-directional swipes. Yes, not just up, down, left or right, but diagonal too
global SwipeTime , SwipeLeft , SwipeRight , SwipeUp , SwipeDown
SetVirtualResolution(480,800) : SetDisplayAspect(480/800)
do
test=GetSwipe(0.1,30)
if test= 0 then flag$=""
if test= 1 then flag$="Left"
if test= 2 then flag$="Right"
if test= 4 then flag$="Up"
if test= 5 then flag$="Left/Up"
if test= 6 then flag$="Right/Up"
if test= 8 then flag$="Down"
if test= 9 then flag$="Left/Down"
if test=10 then flag$="Right/Down"
If GetRawKeyPressed(27)=1 then END
Print(Flag$)
Sync()
loop
function GetSwipe(t#,s)
output=0
If GetPointerState()=0 then SwipeTime=Timer()+t#
If GetPointerPressed()=1 then SwipeRight=GetPointerX()+s
If GetPointerPressed()=1 then SwipeLeft=GetPointerX()-s
If GetPointerPressed()=1 then SwipeDown=GetPointerY()+s
If GetPointerPressed()=1 then SwipeUp=GetPointerY()-s
If GetPointerState()=1 and SwipeTime<Timer()
If SwipeLeft>GetPointerX()
SwipeTime=0 : output=output+1
EndIf
If SwipeRight<GetPointerX()
SwipeTime=0 : output=output+2
EndIf
If SwipeUp>GetPointerY()
SwipeTime=0 : output=output+4
EndIf
If SwipeDown<GetPointerY()
SwipeTime=0 : output=output+8
EndIf
endif
endfunction output
Cheers, Ian.
http://www.zortokgames.com
www.zortokgames.com