How to move to the next scene
by Gagan · in iTorque 2D · 07/23/2009 (9:32 am) · 7 replies
I want to move to the next level or scene on a tap....
pls suggest code for that
thanks
pls suggest code for that
thanks
#2
sceneWindow2D is current or next level??
07/23/2009 (9:54 am)
could u pls explain me the parameters...sceneWindow2D is current or next level??
#3
schedule is a method with parameters: (time, function, functionParams)
To breakdown the parameters:
time: 20 ms
function: loadLevel
functionParams: game/data/levels/NextLevelHere.t2d <---- this is the next level
This will call sceneWindow2D.loadLevel("game/data/levels/NextLevelHere.t2d") after 20ms.
07/23/2009 (10:31 am)
sceneWindow2D is the default name of the primary window where objects are drawn.schedule is a method with parameters: (time, function, functionParams)
To breakdown the parameters:
time: 20 ms
function: loadLevel
functionParams: game/data/levels/NextLevelHere.t2d <---- this is the next level
This will call sceneWindow2D.loadLevel("game/data/levels/NextLevelHere.t2d") after 20ms.
#4
The only trick is that these need to be run via schedule. So what I would do is the following:
First put the endlevel and load level into a function named:
Then when you want to goto the next levle do the following:
sceneWindow2D.schedule(20,"nextLevel","levelname");
If you don't run those two commands inside a schedule operation it will usually crash. Also if you don't call endLevel() before loadLevel() you will eventually run out of memory.
07/23/2009 (11:16 am)
It's actually a little more to it than that. You need to do 2 thingsSceneWindow2D.endLevel();
SceneWindow2D.loadLevel("levelname"); The only trick is that these need to be run via schedule. So what I would do is the following:
First put the endlevel and load level into a function named:
function nextLevel(%levelname) {
SceneWindow2D.endLevel();
SceneWindow2D.loadLevel(%levelname);
}Then when you want to goto the next levle do the following:
sceneWindow2D.schedule(20,"nextLevel","levelname");
If you don't run those two commands inside a schedule operation it will usually crash. Also if you don't call endLevel() before loadLevel() you will eventually run out of memory.
#5
In levelManagement.cs:
07/23/2009 (1:25 pm)
Why would run out of memory if you don't call endLevel() first? I had a look at the source code for loadLevel() and it calls endLevel() for you.In levelManagement.cs:
//---------------------------------------------------------------------------------------------
// t2dSceneWindow.loadLevel
// Loads a level file into a scene window.
//---------------------------------------------------------------------------------------------
function t2dSceneWindow::loadLevel(%sceneWindow, %levelFile)
{
// Clean up any previously loaded stuff.
%sceneWindow.endLevel();
#6
07/23/2009 (1:50 pm)
I didn't realize it called endLevel for you. I stand corrected.
#7
07/23/2009 (1:55 pm)
this discussion proved out to be beneficial...thanks guys
Nate Gertsch