Hi.
I wrote a code with for loop that create two Column sprites (as coin). now I check collision between the player and coins. then I want if collision is true, hide coins. but there is an Problem that when I collide to coin sprite, only one coin hide.Please Guide me for fix this Problem.
this is my code:
// set display properties
SetVirtualResolution( 1024, 768 )
SetPhysicsGravity (0,10000)
player = CreateSprite (0)
SetSpriteSize (player,55,150)
SetSpriteColor (player, 255,43,43,255)
SetSpritePosition (player,20,600)
SetSpritePhysicsOn(player,2)
spr = CreateSprite (0)
SetSpriteVisible(spr,0)
global dim Diamond [12]
for i = 1 to 6
if GetSpriteExists(Diamond[i]) = 0 then Diamond[i] = CloneSprite(spr)
SetSpriteVisible(Diamond[i],1)
SetSpriteSize(Diamond[i],45,-1)
SetSpritePosition (Diamond[i],200+i*60, 650)
for n = 7 to 12
if GetSpriteExists (Diamond[n]) = 0 then Diamond[n] = CloneSprite(spr)
SetSpriteVisible(Diamond[n],1)
SetSpriteSize(Diamond[n],45,-1)
SetSpritePosition (Diamond[n],200+(n-6)*60, 700)
Next n
Next i
do
if GetRawKeyState (39) = 1
SetSpritePosition (player,GetSpriteX(player)+5,GetSpriteY(player))
else
SetSpritePosition (player,GetSpriteX(player),GetSpriteY(player))
endif
if GetRawKeyState (37) = 1
SetSpritePosition (player,GetSpriteX(player)-5,GetSpriteY(player))
else
SetSpritePosition (player,GetSpriteX(player),GetSpriteY(player))
endif
diacollide = GetSpriteCollision(player,Diamond[i])
if diacollide = 1 then SetSpriteVisible(Diamond[i],0)
Print( ScreenFPS() )
Sync()
loop