setvirtualresolution(960,640)
rem create 3 sprites to represent touch points
CreateSprite( 1, 0 )
SetSpriteColor( 1, 255,0,0,255 )
CreateSprite( 2, 0 )
SetSpriteColor( 2, 0,255,0,255 )
CreateSprite( 3, 0 )
SetSpriteColor( 3, 0,0,255,255 )
dim assigned[3] as integer
do
assigned[1] = 0
assigned[2] = 0
assigned[3] = 0
rem find out which sprites are currently taken
touchID = GetRawFirstTouchEvent(1)
while touchID > 0
sprite = GetRawTouchValue( touchID )
if ( sprite > 0 ) then assigned[sprite] = 1
touchID = GetRawNextTouchEvent()
endwhile
rem move assigned sprites to touch locations
touchID = GetRawFirstTouchEvent(1)
while touchID > 0
x# = GetRawTouchCurrentX( touchID )
y# = GetRawTouchCurrentY( touchID )
printc(x#) : printc(" ") : print(y#)
sprite = GetRawTouchValue( touchID )
if ( sprite = 0 )
rem assign this new touch point a sprite
if ( assigned[1] = 0 )
sprite = 1
elseif ( assigned[2] = 0 )
sprite = 2
elseif ( assigned[3] = 0 )
sprite = 3
endif
SetRawTouchValue( touchID, sprite )
endif
if ( sprite > 0 )
SetSpritePosition( sprite, x#, y# )
endif
touchID = GetRawNextTouchEvent()
endwhile
Print( GetRawTouchCount(1) )
Sync()
loop
function ZoomTouch() if GetMultiTouchExists() =1 if GetRawTouchCount(1)=2 //two Fingers t=GetRawFirstTouchEvent(1) sx1#=GetRawTouchStartX(t) sy1#=GetRawTouchStarty(t) x1#=GetRawTouchCurrentX(t) y1#=GetRawTouchCurrenty(t) t=GetRawNextTouchEvent() sx2#=GetRawTouchStartX(t) sy2#=GetRawTouchStarty(t) x2#=GetRawTouchCurrentX(t) y2#=GetRawTouchCurrenty(t) //drawline(sx1#,sy1#,sx2#,sy2#,255,255,255) //drawline(x1#,y1#,x2#,y2#,0,255,0) dx#=sx2#-sx1# dy#=sy2#-sy1# l1#=sqrt(dx#*dx# + dy#*dy#) //distance start 1 - start 2 dx#=x2#-x1# dy#=y2#-y1# l2#=sqrt(dx#*dx# + dy#*dy#) //distance current 1 - current 2 if l1#>0 l#=(1.0 / l1#) * l2# l#=l#-1.0 l#=l#/3.0 //slower z#=getviewzoom()+l# if z#<1.0 then z#=1.0 //Limit if z#>2.5 then z#=2.5 //Limit setviewzoom(z#) endif endif endif endfunction ret