Game Development Community

Continue Game Level

by Temasek Polytechnic (#0001) · in Torque X 2D · 01/23/2008 (5:42 pm) · 12 replies

Hi,

Is there any tutorial on how to codes the game so that we are able to continue next level when we finish the first level?

#1
02/14/2008 (1:22 pm)
If you put each level into a scene, you could load a new scene and unload hte previous scene. This has been discussed in the forums already
#2
02/17/2008 (6:25 pm)
Hi,

I have tried to search through the forum but i could not find the loading of each scene. Are you able to provide the link for me? (will continue to re-search again myself too (^__^) )
#3
02/17/2008 (7:27 pm)
In TGB, you simply say something like:

startGame("game/data/levels/mylevel.t2d");

Replace "mylevel.t2d" with the filename of your desired level.

Of course the entire thing could be different for TXB. I don't really know if this translates or not. Worth a try, eh?
#4
02/17/2008 (7:42 pm)
Hi Kevin,

For TXB, we say something like:
SceneLoader.Load(@"data\levels\space.txscene");
I think i see some similar in the way it tries to load the scene out.

Let assume TGB and TXB are the same, so how do you actually load from one level to another level after completion of the first level?

Example:
Level 1: SceneLoader.Load(@"data\levels\space.txscene");
Level 2: SceneLoader.Load(@"data\levels\underwater.txscene");

How do i load from space to underwater??
#5
02/17/2008 (7:58 pm)
Alright, so your problem isn't the actual code for loading the level --- its the logic of signaling that a level is completed, then loading the appropriate level. I'd really have to know how your game works - even just the genre - to appropriately suggest a solution, but most times a trigger would work well for such things.
#6
02/17/2008 (10:26 pm)
When the player reaches the final checkpoint for space.txscene, it will pop up a image showing Congratulations on Completion of Level 1 etc. After that, i would like the player to continue next level underwater.txscene.

We actually intend to have 3levels for our game. So now even though we have different level (scene) but we are unable to combine it together. In the sense that, when the player complete first level, it will load second level immediately.

Sorry to ask, but what do you mean by trigger?

Thank you so much for your time. =)
#7
02/17/2008 (11:20 pm)
Can you create a class or struct that contains all the needed field you need to pass. After the player finishes a level, just pass all the player's data to the class or struct you just created. And then send those data to the new player in the next level.

Aun.
#8
02/18/2008 (6:10 am)
Temasek,

You know how you have static sprites, scene objects, particle effects and etc.? A trigger is another kind of object. Its unique because it has onEnter, onStay and onLeave callbacks. TXB should have them wherever the objects creation panel is. Here's what I'd do:

1.) Create trigger at desired checkpoint - stretching the bounds to fit the best way.
2.) Give the trigger a class in the level builder. ex: "endLevelTrigger"
3.) Create your "Congratulations" message where your last check point is. Turn the visibility off. Give it a name like "congratulationsMessage".
4.) Create this function:

function endLevelTrigger::onEnter(%this, %object)
{
      //simply check if the entering object [i]is[/i] the player
      //you should add a class to the player if you haven't already:
      if(%object.class $= "player")
      {
             //show the congratulations message
             congratulationsMessage.visible = true;
             //load the level in 2 seconds
             schedule(2000, "", "startGame", "game/data/levels/mylevel.t2d");
      }
}

Hope this works out for you. You'll definitely need to convert it into TXB script. You should consult the TXB documentation for help translating it into something useful.

It seems like Aun is on to something, but you'll have to seek further guidance from him on the matter.
#9
02/18/2008 (7:40 pm)
Hi Aun,

Thank you for your suggestion, it was a nice one. I have just created a new class for proceed to new level. Then i used the way Kevin suggested, yes the next scene comes out. But, the old scene does not go off. As in, scene1 and scene2 combined together and i see 2platform and 2players. What should i add on in order to makes the scene1 disable before loading scene2??

----------------------------------------------
Hi Kevin,

Your suggestion was great. But somehow the time part does not work for TXB. Guess i need to read more on the documentation to figure out how to put the time schedule in. By the way, how do you make scene1 disable before loading scene2?

----------------------------------------------
Thanks Aun and Kevin for your reply and suggestion. (^_^)
#10
02/19/2008 (4:39 am)
You have to unload your current scene first

SceneLoader.UnloadLastScene();
#11
02/19/2008 (4:55 am)
Zilla's suggestion sounds like the ticket. The schedule may not even be necessary, you should experiment a little with it, Temasek.
#12
02/26/2008 (7:59 pm)
Hi, Sorry to disturb again. Yes i have success in loading the scene from one level to another level without overlapping. But now my concern is, my points/lifes etc doesnt not bring over to the next level. How should i do about it? I tries using xml but seems like i fail, and the whole level just stucked there.

Anyone have suggestion of tutorial on xml??

Thank you so much for your time and effort.