Hi.
I created a side scroll game and created function for my enemies that them move from right screen to left.
Now I want when (myenemy[i] = destroy or myenemy[i] = out of screen) load enemy function again.
Please Guide Me.
SetDisplayAspect( -1 )
global player as integer
global dim BatSprite[10] as Integer
global BatEmptySprite as Integer
CreatePlayer()
CreateBat()
do
MoveBat()
//Move Screen
SetViewOffset(GetViewOffsetX() + 0.5,GetViewOffsetY())
//Control Player Up and Down
if GetrawkeyState(38) = 1
SetSpritePosition(player,GetSpriteX(player),GetSpriteY(player) - 0.75)
else
if GetrawkeyState(40) = 1
SetSpritePosition(player,GetSpriteX(player),GetSpriteY(player) + 0.75)
endif
endif
//Control Player Left and Right
if GetRawKeyState(39) = 1
SetSpritePosition(player,GetSpriteX(player) + 0.75,GetSpriteY(player))
else
if GetRawKeyState(37) = 1
SetSpritePosition(player,GetSpriteX(player) - 0.1,GetSpriteY(player))
else
SetSpritePosition(player,GetSpriteX(player) + 0.5,GetSpriteY(player))
endif
endif
Sync()
loop
//===>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> START Functions
// Create Player
Function CreatePlayer()
player = CreateSprite(0)
SetSpriteAnimation(player,250,160,2)
SetSpritepositionByOffset(player,15,50)
SetSpriteSize(player,10,-1)
EndFunction
//Create bat Enemies
Function CreateBat()
BatEmptySprite = CreateSprite(0)
SetSpriteVisible(BatEmptySprite,0)
for a = 1 to 3
if GetSpriteExists(BatSprite[a]) = 0 then BatSprite[a] = CloneSprite(BatEmptySprite)
SetSpriteVisible(BatSprite[a],1)
SetSpriteSize(BatSprite[a],10,-1)
SetSpritePosition(BatSprite[a],Random(100,400),Random(5,80))
SetSpriteColor(BatSprite[a],255,0,0,255)
next a
EndFunction
// Move Bat
Function MoveBat()
for a = 1 to 3
if GetSpriteExists(BatSprite[a]) = 1
SetSpriteposition(BatSprite[a],GetSpriteX(BatSprite[a])-0.1,GetSpriteY(BatSprite[a]))
endif
next a
for i = 1 to 3
if GetSpriteExists(BatSprite[i]) = 1
if WorldToScreenX(GetSpriteX(BatSprite[i])) < 0
DeleteSprite(BatSprite[i])
endif
endif
next i
EndFunction
//===>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> END Functions