Loading saved games (woes and more woes)
Posted: Thu Feb 16, 2006 2:14 am
I feel like I've learned a lot about using Game Editor in the past few months (mainly thanks to you guys) and my first game is all but complete...but for the life of me I have not been able to successfully add even A SINGLE ONE of the handful of features I wanted to add...frustrating!!!
The latest issue is that I can't properly load saved games. There are only three variables I need to save: level, score, and lives. Simple right? I know how to use saveVars/loadVars (I use them to store and retrieve the highscore), but everything is messed up when I try to use them to restore these three variables (savedLevel, savedScore, and savedLives).
Here's what I did:
(1) Created a global int gameInProgress (part of the "save" group). Its value is 0 by default. When the MainShip is created, gameInProgress is set equal to 1. When the player loses all lives (i.e., when the game is over) it is set back to 0. If the player presses the exit button before the game is over, the three variables (level, score, and lives) are saved as savedLevel, savedScore, and savedLives (in the "save" group). gameInProgress (now equal to 1) is also saved.
(2) When the player restarts the game, the "save" group is loaded and if gameInProgress == 0, the game starts as it normally would. If, however, gameInProgress == 1, then the title screen is avoided and the game starts as it normally would, except that level, score, and lives are set equal to savedLevel, savedScore, and savedLives. Simple enough right?
The problem is that a whole bunch of stuff goes wrong: actors lose their parent-child relationships (even though I included these commands in script; the fire button always shoots in one direction (to the side of the screen, etc.).
These problems are reminiscent of problems I've had in the past that occurred when events were sent to actors that were outside of the activation region, but I can't understand why. Why should the activation region matter for variable assignment?
Can anyone figure anything out?
Thanks in advance,
[A whimpering] Plinydogg
The latest issue is that I can't properly load saved games. There are only three variables I need to save: level, score, and lives. Simple right? I know how to use saveVars/loadVars (I use them to store and retrieve the highscore), but everything is messed up when I try to use them to restore these three variables (savedLevel, savedScore, and savedLives).
Here's what I did:
(1) Created a global int gameInProgress (part of the "save" group). Its value is 0 by default. When the MainShip is created, gameInProgress is set equal to 1. When the player loses all lives (i.e., when the game is over) it is set back to 0. If the player presses the exit button before the game is over, the three variables (level, score, and lives) are saved as savedLevel, savedScore, and savedLives (in the "save" group). gameInProgress (now equal to 1) is also saved.
(2) When the player restarts the game, the "save" group is loaded and if gameInProgress == 0, the game starts as it normally would. If, however, gameInProgress == 1, then the title screen is avoided and the game starts as it normally would, except that level, score, and lives are set equal to savedLevel, savedScore, and savedLives. Simple enough right?
The problem is that a whole bunch of stuff goes wrong: actors lose their parent-child relationships (even though I included these commands in script; the fire button always shoots in one direction (to the side of the screen, etc.).
These problems are reminiscent of problems I've had in the past that occurred when events were sent to actors that were outside of the activation region, but I can't understand why. Why should the activation region matter for variable assignment?
Can anyone figure anything out?
Thanks in advance,
[A whimpering] Plinydogg