rem rem AGK Application 1.08 19 rem MR SetDisplayAspect( 4.0/3.0 ) spr = CreateSprite(0) SetSpriteSize (spr, 10.0, -1) SetSpritePositionByOffset (spr, 50.0, 50.0) do print("click/hold and move a sprite") mx#=ScreenToWorldX(GetPointerX()) my#=ScreenToWorldY(GetPointerY()) if getpointerpressed()=1 HitTest = GetSpriteHitTest ( spr, mx#, my# ) //click offset ox# = mx# - GetSpriteXbyoffset ( spr ) oy# = my# - GetSpriteYbyoffset ( spr ) endif if getpointerreleased()=1 HitTest = 0 endif if GetPointerState() = 1 and HitTest=1 dx# = mx# - GetSpriteXbyoffset ( spr ) - ox# dy# = my# - GetSpriteYbyoffset ( spr ) - oy# l# = sqrt ( dx#*dx + dy#*dy# ) if l#>0.0 dx#=dx# / 10.0 dy#=dy# / 10.0 nx#=GetSpriteXbyoffset ( spr ) + dx# ny#=GetSpriteybyoffset ( spr ) + dy# SetSpritePositionbyoffset ( spr, nx#, ny# ) endif Endif Sync() loop