I made a simple example, it may be useful
SetErrorMode(2)
SetWindowTitle( "Card array" )
SetWindowSize( 400, 710, 0 )
SetWindowAllowResize( 1 )
//==============================================================
global AppWidth,AppHeight
AppWidth = 640
AppHeight = 640*GetDeviceHeight()/GetDeviceWidth()
SetVirtualResolution( AppWidth, AppHeight )
//==============================================================
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 30, 0 )
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 )
//==============================================================
type class_card
id as integer
image as integer
state as integer
press as integer
endtype
global card as class_card[4]
//--------------------------------------------------------------
global image_back : image_back = LoadImage("back.png")
for i = 1 to card.length
card[i].id=CreateSprite(image_back)
card[i].image=LoadImage("q"+str(i)+".png")
card[i].state = 0
card[i].press = 0
SetSpriteScaleByOffset(card[i].id, 0.8, 0.8)
SetSpritePositionByOffset(card[i].id, GetSpriteWidth(card[i].id)/2*i+AppWidth/6, AppHeight/2 )
next i
global LastPress = -1
//==============================================================
do
CardPress()
Sync()
loop
//==============================================================
function CardPress()
if GetPointerPressed() = 1
for i = card.length to 1 step -1
if GetSpriteHitTest(card[i].id, GetPointerX(), GetPointerY()) = 1
//--------------------------------------------------------------
for k = 1 to card.length
SetSpritePositionByOffset(card[k].id, GetSpriteWidth(card[k].id)/2*k+AppWidth/6, AppHeight/2 )
SetSpriteImage(card[k].id, image_back)
card[k].press = 0
next k
//--------------------------------------------------------------
if LastPress <> i
SetSpritePositionByOffset(card[i].id, GetSpriteXByOffset(card[i].id), GetSpriteYByOffset(card[i].id)-70)
SetSpriteImage(card[i].id, card[i].image)
card[i].press = 1
LastPress = i
else
LastPress =-1
endif
//--------------------------------------------------------------
exit
endif
next i
endif
endfunction