Game Development Community

Loading Scenes in TGB

by Niccolo\\\\\\\" · in Torque Game Builder · 02/20/2007 (7:22 am) · 3 replies

Why does not exist this function in TGB?

Tnk for reply.

Equinox

#1
02/20/2007 (8:37 am)
@Niccolo -- define 'scene' ?

TGB Supports loading Levels, using the sceneWindow2D.loadLevel() method -- if thats what you mean.
#2
02/20/2007 (10:32 am)
Tnk for reply. Sorry for my error.

I meant to "save the state of the game"

until where me have arrived in order then to resume it from the same point of the "save the state of the game"

Tnk1000 :o)))
#3
02/20/2007 (12:52 pm)
@niccolo, as every game differs quite a bit from each other, it's impossible for GG to 'guess' what sort of 'save state' system you would need -- you would have to implement your own save-state system in order to have one.

However, depending on your requirements, this could be very simple, or fairly complex --

Some examples are as follows;

Use a ScriptObject to store simple State data:
new ScriptObject(gameState)
{
  currentLevel = "game/data/levels/level.t2d";
  currentScore = 50;
  currentPlayer = "MoZ";
};

gameState.save("~/data/save.state");

All you would have to do in this case, is exec("~/data/game.state}); and your 'gameState' object would then contain the last state saved to disk -- this would allow for simple game state saving, however, keep in mind, this game-state is a TorqueScript file -- to ensure it compiles, exec() it after saving it, then delete the '.state' file and keep the game.state.dso file --

Another option, is to build a SimSet of all the objects you want to know about in your state, then perform a SimSet.save() and write out the entire SimSet ... then use the same method as above, to rebuild your level from the objects in the SimSet (such as possible NPC's, etc, etc)


Lots of possibilities ... there is also a 'Finite State Machine' resource that was just recently posted --