The part about the reseting variables thing was a theory... And still is
Anyway the problem im experiencing is that When I start the game, the game sets the resolution and #includes all files, then go to the main menu. When there you press play game and the game runs fine. But if you return to the menu after playng and loading evrything, the game deletes all Media used
IF hasran=1
//Deleting evrything to make sure nothing is loaded twice
For i=1 to 50000
If GetSpriteExists(i)
DeleteSprite(i)
endif
If GetImageExists(i)
DeleteImage(i)
endif
If GetTextExists(i)
DeleteText(i)
endif
If GetParticlesExists(i)
DeleteParticles(i)
endif
next i
Score.Kills=0
Score.ShipsAtIsland=0
Score.Damage=0
For i=1 to 4
If GetVirtualJoystickExists(i)
DeleteVirtualJoystick(i)
endif
next i
For i = 1 to 12
if GetVirtualButtonExists(i)
DeleteVirtualButton(i)
endif
next i
endif
The menu is fine, but if you press play game again the game crashes imedietly, without an error or anything, the game shuts down.
The fact that I delete evrything when going back to the menu makes me believe that media loaded twice is not the issue. But what I don't do is reset all variables, Removing arays and types or anything like that. Wich Is what I believe is causing a crash.
I did a test though in wich I created both an array and a type inside a loop and it didn't crash.
Allso, on an older version of the game that I had on my android phone, the crash didn't happen untill restarting about 7 times. The game did however create some random "dummy sprites (white boxes)".