Game Development Community

SceneWindow2D.loadLevel Crashes

by Seth Willits · in Torque Game Builder · 05/02/2008 (7:53 pm) · 2 replies

I have a new project set up, and I copied over the genericButton behavior from the playground project, and I have the button calling a function in which I do... sceneWindow2D.loadLevel("game/data/levels/level.t2d") and it crashes TGB. Seems kinda... wrong. If I load level.t2d as the default level with startGame() then it works just fine there, but I'm trying to switch to it from my title screen and it goes kablamo.

Any thoughts?

#1
05/03/2008 (2:28 am)
The loadLevel function unloads the assets of your current level then loads the new level you specify. You can't have a button that is being unloaded call a new level - TGB crashes as a result.

For a solution see the last section of the asteroids tutorial:
tdn.garagegames.com/wiki/TGB/Tutorials/Asteroids/Section9
#2
05/03/2008 (7:53 am)
I did finally figure out that you had to use schedule in the button's callback to eventually call loadLevel. The tutorial glosses over what the schedule is for, so that wasn't exactly clear. At any rate, crashing isn't ideal; a warning in the console would have been a whole lot more useful.