Game Development Community

$Game::DefaultScene mysterously changing value

by Sam Burns · in Torque Game Builder · 02/04/2012 (8:12 am) · 6 replies

Hi,

Note: I am using Torsion to debug this project.

Now that I can debug my project I can look at the problem I was having. Unfortunately I have run into another problem. When I go into debug mode the game tries to load the untitled.t2d level. The curious thing is that the defaultscene is set right when the startGame function is called but when it gets into the startGame function it has changed. The CallStack shows two levels: startGame which we are in and initializeProject. When I double click on initializeProject I hover over $Game::DefaultScene in the startGame function call. It says:

"~/data/levels/level1.t2d" which is the level I have created.

Then I double click (on the call stack) the startGame call and it takes me to the startGame function, I hover over the %level parameter and it says "game/data/levels/untitled.t2d".

Something somewhere is changing the parameter but it only seems to be in debug mode. If I run it in release the game starts up fine. When I step through startGame it gets to sceneWindow2D.loadLevel(%level);
and reports "Error loading level game/data/levels/untitled.t2d. Invalid file." and gives me a black screen.

commonConfig.xml has the following for the default scene = "<DefaultScene>~/data/levels/level1.t2d</DefaultScene>"

Any ideas?

#1
02/05/2012 (3:33 am)
Is there a reason to set default scene through the script and not with the defaultScene parameter of the commonConfig? TGB has this parameter because every game has an entry-point scene that is always the same - splash screen, main menu or whatever.

As to differences between debug and release, only thing I can think of is different settings for these within Torsion.
#2
02/05/2012 (4:34 am)
The default scene has been set by tgb, I only have one level at the moment :) It just seems really peculiar that the this parameter value changes almost like the engine is doing something as it parses the script, I'm not shying away from diving into the engine but I don't want to get into the habit of assuming that every bug is an engine issue. I am assuming that this is a config issue at the moment.
#3
02/05/2012 (6:00 am)
Ok this seems to have resolved itself also. I simply moved the breakpoint to a point after the startGame call and it seems to load the right level. Not sure if this a timing issue, a Torsion issue or what but it has gone away without really doing anything.

But its from one problem to another it seems. I'm not getting the expected results from castCollision. Have gone through the platform tutorial and castCollision seems to be picking up the collision with the tilegrid at the beginning only. A castCollision(0.005) picks up the tile grid below me on the first call so the player does a jump. Then when he lands you try to do a jump again the castCollsion(0.005) returns "". This is the same code as the first jump - very annoying, am gonna try pickLine next. Can anyone tell me if castCollsion is supposed to work with a tile grid because the same problem with the same code doesn't seem to occur if I just drag an object onto the screen and set it to receive collisions.
#4
02/05/2012 (6:56 am)
A bit more info on this. When I start the level the position of the player is [3.000000, 21.990000] after I have done the first jump the player is in position [3.000000, 21.998001] and won't jump. But if I do a setPositionY(21.990000) in the console the player will do a jump again. On this occasion the next time I jumped the position was then [3.000000, 21.997999].

I have increased the castCollsion time to 1 sec and it still doesn't see the floor. It's like after I have landed I am partially through the floor so that the castCollision picks nothing up. This being the case I don't think pickLine will make any difference.
#5
02/06/2012 (1:53 pm)
I've been having the same issue with Torsion and TGB. Sometimes I hit run in Torsion and it errors out with not being able to load untitled.t2d, other times it runs fine. I haven't been able to pin down any consistency with it other than it seems like if I go to TGB and hit run, then close it and go back to Torsion and hit run it usually works.
#6
03/13/2012 (3:20 am)
I get this too.

1) Just open Torsion and try to run. "Error loading level game/data/levels/untitled.t2d. Invalid file."
2) Open T2D, run from there, stop.
3) Flip back to Torsion - problem fix - runs as normal.