Game Development Community

Trouble changing scenes/levels

by Brian E Charapata · in iTorque 2D · 12/01/2011 (6:17 am) · 2 replies

I am trying to create a set of splash screens, company first then game splash. To do this I have created two scenes and put as a background .png the splash screens. Nothing fancy simply displaying them.

The first scene displays fine. Then there is a pause and I (try) to remove the first scene then start the second scene. The end result is that I end up with the second scene overlaying the first scene.

Here is the code:

Call first splash scene

game.cs
function initializeGame()
{
   setResolution();
   startGame( expandFilename($Game::CSplashScene) );
}

defaultPrefs.cs
$Game::CSplashScene         = "data/levels/splashLevel.t2d";
$Game::GSplashScene         = "data/levels/gsplashLevel.t2d";

Doing the rest of the scene calls.

game.cs
function startGame(%level)
{
	$currentScene = %level;
	
	%sceneTime = 3000;
	%companySplash = %level;
	%gameSplash = expandFilename($Game::GSplashScene);
.
.
.
	// Do splash screens first
	// this is company logo
	startSplash( %companySplash );
	
	// Now do game splash
	schedule(2000, 0, "endScreen", %companySplash );
	schedule(%sceneTime, 0, "startSplash", %gameSplash );
.
.
.

The rest of startGame() is pretty much left alone as far as the other code goes.
Here are the last parts.

//------------------------------------------------------------------------------
// startSplash
// bring up Splash scene. 
function startSplash(%level)
{
   // Load the .t2d file for this game
   sceneWindow2D.loadLevel(%level);
}

// End scene
function endScreen()
{
echo( "**************" );
echo( "  endScreen n" );
	sceneWindow2D.endLevel();
   	moveMap.pop();
   	moveMap.delete();
}

I'm not sure what to do. I have followed several forum searchs and tried the examples. None have worked to resolve the issue.


#1
12/06/2011 (7:23 am)
Any warnings or errors in the console log related to the code? Also, are those echos for the endScreen function printing out?
#2
12/06/2011 (5:17 pm)
Hi Michael thanks for replying.
I checked the log. No errors. Yes the echos are printing. Here is the portion of the log which seems applicable.
/Applications/iTorque2D_1_5/MyProjects/Test-ChangeScenes/projectFiles/gui/mainScreen.gui. Took 0 ms
 % - MainScreen set to Portrait! 320x480
 % - Game load time : 212 ms
--------Adding to Level data/levels/splashLevel.t2d
--------Exec()ing level datablocks data/levels/datablocks/splashLevel_datablocks.cs
Loaded compiled script /Applications/iTorque2D_1_5/MyProjects/Test-ChangeScenes/projectFiles/data/levels/datablocks/splashLevel_datablocks.cs. Took 128 ms
--------Exec()ing level data/levels/splashLevel.t2d
Compiling /Applications/iTorque2D_1_5/MyProjects/Test-ChangeScenes/projectFiles/data/levels/splashLevel.t2d...
creating path /Applications/iTorque2D_1_5/MyProjects/Test-ChangeScenes/projectFiles/data/levels/splashLevel.t2d.dso
Found the iPadSet
Loaded compiled script /Applications/iTorque2D_1_5/MyProjects/Test-ChangeScenes/projectFiles/data/levels/splashLevel.t2d. Took 0 ms
 % - MainScreen set to Portrait! 320x480
**************
  endScreen 

--------Adding to Level data/levels/gsplashLevel.t2d
--------Exec()ing level datablocks data/levels/datablocks/gsplashLevel_datablocks.cs
Loaded compiled script /Applications/iTorque2D_1_5/MyProjects/Test-ChangeScenes/projectFiles/data/levels/datablocks/gsplashLevel_datablocks.cs. Took 128 ms
--------Exec()ing level data/levels/gsplashLevel.t2d
Found the iPadSet
Loaded compiled script /Applications/iTorque2D_1_5/MyProjects/Test-ChangeScenes/projectFiles/data/levels/gsplashLevel.t2d. Took 0 ms
 % - MainScreen set to Portrait! 320x480
creating path scripts/system/prefs.cs
creating path scripts/system/prefs.cs
creating path scripts/system/prefs.cs
creating path scripts/system/prefs.cs
creating path scripts/system/prefs.cs
Shutting down the OpenGL display device...
Cleaning up the display device...
Killing the texture manager...
Clearing the current AGL context...
Clearing the current drawable...
Deleting the rendering context...
Destroying the window...

I ran it again before this reply. Same double image with the second overlaying the first after the pause.
Brian