Quick Multi Touch Example by LeeBamber22nd Oct 2011 22:46
|
---|
Summary Demonstrates Multi-Touch in AGK Description Though not universal, you can use raw commands to gather multi-touch information from supported devices such as the iPad. Find code here which very quickly demonstrates how this can be created. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com rem Landscape App SetDisplayAspect( 4.0/3.0 ) 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 assigned to points 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 ) 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 Sync() loop |