this is an example code for delete objects:
SetDisplayAspect(-1)
`variables
global player
global ground
//call game function
Game()
Function Game()
//Create Player
player = CreateSprite(0)
SetSpritePositionByOffset(player,50,90)
SetSpriteSize(player,7,-1)
//Create grounds
ground = CreateSprite(0)
SetSpriteColor(ground,255,0,0,255)
SetSpriteSize(ground,100,5)
SetSpritePosition(ground,0,95)
do
if GetSpriteExists(player) = 1
Print("Press Enter to delete Objects")
if GetRawKeyState(39) = 1 //move to right
SetSpritePosition(player,GetSpriteX(player)+0.5,GetSpriteY(player))
elseif GetRawKeyState(37) = 1 //move to left
SetSpritePosition(player,GetSpriteX(player)-0.5,GetSpriteY(player))
endif
endif
//Delete Objects after Press Enter Key
if GetRawKeyPressed(13) = 1
DeleteObjects()
endif
Sync()
loop
EndFunction
//////////////////////////////////Function Delete ojects
Function DeleteObjects()
DeleteSprite(player)
DeleteSprite(ground)
EndFunction