(AGK version: 108.24)
Submitted: 2014-09-20 19:42:14
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
Help make AGK better by submitting an example for this command!
(All examples are subject to approval)
Login to post an example of your own.