Continue, a main menu feature
by rennie moffat · in Torque Game Builder · 04/27/2010 (8:40 am) · 4 replies
I want to build a "continue" feature in my game. Thus I need to set up a global variable that will be triggered, set when the game is exited. This will be easy enough I think when a user hits my "exit game" button. but what about when the user hits the actual devices "exit" button? (iPhone, iPod etc). I have seen many games do this, but I am not sure how/if i can record my current level, sceneGraph etc if this button is hit.
Any insight?
Thanks.
edit. reposting in iTGB, if this is a problem please take down this thread.
:)))
Any insight?
Thanks.
edit. reposting in iTGB, if this is a problem please take down this thread.
:)))
About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.
#2
since I can't see any docs that use saveProfile I am a little iffy on it. but I do appreciate it.
What I am doing instead is when I press my menuBtn (which will exit from the game) I set a global...
the problem is I thought it would return the name I had given my sceneGraph for that level. It doesn't, it returns a number. And a random one at that, each time is different. So if any one can help me work through this, I would appreciate it. In the mean time I will try Ben's help. Thank you.
04/27/2010 (10:15 am)
Thanks ben, since I can't see any docs that use saveProfile I am a little iffy on it. but I do appreciate it.
What I am doing instead is when I press my menuBtn (which will exit from the game) I set a global...
$contLevel= sceneWindow2D.getSceneGraph();
the problem is I thought it would return the name I had given my sceneGraph for that level. It doesn't, it returns a number. And a random one at that, each time is different. So if any one can help me work through this, I would appreciate it. In the mean time I will try Ben's help. Thank you.
#3
As for the variable you are using it will store a reference to the object not the actual object. I don't really advise that method anyway as you don't really need to save the entire scenegraph do you? Just its state.
04/27/2010 (10:27 am)
Rennie saveProfile is and its related objects / methods are custom made by me and outlined in the resource I linked.As for the variable you are using it will store a reference to the object not the actual object. I don't really advise that method anyway as you don't really need to save the entire scenegraph do you? Just its state.
Torque Owner Ben Versaw
For saving there are multiple methods. In casual games I save the profile ( $CurrentProfile.SaveProfile() ) anytime I change properties of the profile. But you might use checkpoints.
For example: Say you player just passed checkpoint 1 on level 1 do this:
$CurrentProfile.currentState = 1;
$CurrentProfile.currentSubstate = 1;
$CurrentProfile.SaveProfile();
This will work even if the user exits because whenever an important change happens you save it right away.
Then for a continue button you could have a method like so:
function continueMethod() { switch( $CurrentProfile.currentState ) { case 1: continueMethodLevel1($CurrentProfile.currentSubstate); case 2: // So on } } function continueMethodLevel1(%subState) { switch( $CurrentProfile.currentSubstate ) { case 1 = checkpoint 1 case 2 = checkpoint 2 // so on } }