Thanks! I tried setting the finger update on pause for 0.05 second when it goes from 2 fingers to 1 finger. That way, it keep the registered position when the player lift both fingers. Seems to work!
// Project: test-twofinger
// Created: 2020-04-24
// show all errors
SetErrorMode(2)
Global arena_width as integer
arena_width = GetMaxDeviceWidth()
Global arena_height as integer
arena_height = GetMaxDeviceWidth() * (16.0/9.0)
rem testing
if GetDeviceBaseName() = "windows"
arena_width = 360
arena_height = 640
endif
SetImmersiveMode( 1 )
SetDisplayAspect (16.0/9.0)
SetBorderColor(0,0,0)
SetClearColor(255,255,255)
rem SET WINDOW PROPERTIES
SetWindowTitle( "test-twofinger" )
SetWindowSize( arena_width, arena_height, 0 )
SetWindowAllowResize( 0 ) // allow the user to resize the window
rem DISPLAY PROPERTIES
SetVirtualResolution( arena_width, arena_height ) // doesn't have to match the window
SetOrientationAllowed( 1, 0, 0, 0 )
SetScissor( GetScreenBoundsLeft(), GetScreenBoundsTop(), GetScreenBoundsRight(), GetScreenBoundsBottom() ) rem use the maximum available screen space, no black borders
//SetSyncRate( 12, 0 )
SetVSync(1)
UseNewDefaultFonts( 1 )
rem used to keep the scale the same despite various resolutions
rem it assume a virtual pixel size of 1440x2560
Global vPx# as float
vPx# = arena_width/1440.0
rem the waiting time before the game registers a shift from two to one finger
global fingerRestTime# as float
fingerRestTime# = 0.05
rem used to count down to fingerRestTime#
global eggWatch# as float
Global rectSID as integer
rectSID = createSprite(0)
setSpriteColor(rectSID, 0,255,0,255)
setSpriteSize(rectSID, 200.0*vPx#, 200.0*vPx#)
global touchActivated as integer
do
touch()
Sync()
loop
function touch()
if GetRawTouchCount(1) > 1 then touchActivated = 1 rem if two or more fingers, "menu" is activated
if GetRawTouchCount(1) = 0 then touchActivated = 0 rem if zero fingers, "menu" menu is deactivated
touchID as integer
touchID = GetRawFirstTouchEvent(1)
if touchActivated = 1
if GetRawTouchCount(1) > 1 then eggWatch# = timer() rem reset the eggwatch while two fingers are down
if GetRawTouchCount(1) > 1 or timer() > eggWatch# + fingerRestTime#
setSpritePosition(rectSID, GetRawTouchCurrentX(touchID)-getSpriteWidth(rectSID)*0.5, GetRawTouchCurrentY(touchID)-getSpriteheight(rectSID)*0.5)
endif
endif
endfunction