Crash on levelload?
by Michael K. · in iTorque 2D · 01/11/2009 (3:57 am) · 6 replies
My game basically switches between a "load screen level" (ex. levelstat.t2d) and the a "game level" (ex. level.t2d). When you press a continue button in the "load screen level" it starts the "game level". When you accomplish "game level" a current level flag gets increased by 1 and then the "load screen level" is started again.
Now heres the issue i am having: I can start my first level and when i accomplish it the "load screen level" is shown... now if i click on the continue button the game hangs still showing the "load screen level".
Since i am only having this problem using "TGBGame.app" from iTGB i am guessing it has to do will the ram being full after the first game level. When starting this using TGB it does everything correct.
Do i have to "free up" memory when switching to the "load screen level"? Or does the last level automatically unload when using the loadLevel-Function?
Any help would be great since i am really puzzled with this problem.
Michael
Now heres the issue i am having: I can start my first level and when i accomplish it the "load screen level" is shown... now if i click on the continue button the game hangs still showing the "load screen level".
Since i am only having this problem using "TGBGame.app" from iTGB i am guessing it has to do will the ram being full after the first game level. When starting this using TGB it does everything correct.
Do i have to "free up" memory when switching to the "load screen level"? Or does the last level automatically unload when using the loadLevel-Function?
Any help would be great since i am really puzzled with this problem.
Michael
#2
What i don't understand is that everything works fine when using tgb.
01/11/2009 (10:04 am)
Thank you eyal. i already tried endLevel(), but unfortunatly it didn't help.What i don't understand is that everything works fine when using tgb.
#3
Thanks!
01/12/2009 (12:19 pm)
Does anyone have anymore suggestions? My game is finished... this is the only problem that i haven't solved yet.Thanks!
#4
When debugging using Torsion I've noticed that it was crashing when exec() all the game scripts in startGame() in game.cs
so I've changed main.cs to first load the mainMenu and then call startGame() using a schedule. I know it doesn't make much sense but It seemed to work. I still get this crash but very very rarely.
here's my new main.cs in /game
Hope it works for you to. let me know if it does.
function initializeProject()
{
exec("~/gui/mainMenu.gui");
Canvas.setContent(mainMenuGui);
sceneWindow2d.schedule(800,mm_startGame);
}
function sceneWindow2d::mm_startGame()
{
exec("./gameScripts/game.cs");
startGame();
}
01/12/2009 (12:28 pm)
I used to have a problem when the game would crash when the iPhone on start.When debugging using Torsion I've noticed that it was crashing when exec() all the game scripts in startGame() in game.cs
so I've changed main.cs to first load the mainMenu and then call startGame() using a schedule. I know it doesn't make much sense but It seemed to work. I still get this crash but very very rarely.
here's my new main.cs in /game
Hope it works for you to. let me know if it does.
function initializeProject()
{
exec("~/gui/mainMenu.gui");
Canvas.setContent(mainMenuGui);
sceneWindow2d.schedule(800,mm_startGame);
}
function sceneWindow2d::mm_startGame()
{
exec("./gameScripts/game.cs");
startGame();
}
#5
01/12/2009 (12:46 pm)
Thanks eyal. My main menu is a level (.t2d), actually everything (highscore, credits, ect) are seperate levels that are called using loadlevel (from my mainmenu.t2d). I am just having a problem when my level (level.t2d) is called twice. The first time it works, the second time it crashes?! But just using itgb not using tgb. Using endlevel() didn't help - but i am still guessing it's a memory issue. The last output from console.log is just: "Loading compiled script game/data/levels/level.t2d". No errors :(
#6
It seems that when using behaviors with itgb 1.1 that changes of a local (!) value (for example %whatever = 1;) are saved across levels. That means if you reuse a behavior in another level your previous local value change is saved in that behavior and you have to reset the value!
That caused a while() to never end in my case!
Good to know...
- Michael
01/13/2009 (5:04 am)
Wow... i finally found the problem!It seems that when using behaviors with itgb 1.1 that changes of a local (!) value (for example %whatever = 1;) are saved across levels. That means if you reuse a behavior in another level your previous local value change is saved in that behavior and you have to reset the value!
That caused a while() to never end in my case!
Good to know...
- Michael
Torque Owner Eyal Erez