Exclude a variable while saving the game

0 favourites
  • 4 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I have a timer based game. In this game there are 4 checkpoints and multiple obstacles.

    Currently, whenever the player reaches the checkpoint I save the game using save game to slot. After saving the game, if the player hits any of the obstacles, the game starts from the saved state.

    However, right now even the timer gets reset to the state when I load the game from slot.

    Is there a way I can save the state of the game except for the timer?

    Tagged:

  • You can create a special object (for example an invisible sprite), and add NoSave behavior to it. Use this object to run the timer and to store different values in its instance variables, which you don't want to be affected by the saving/loading events.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can create a special object (for example an invisible sprite), and add NoSave behavior to it. Use this object to run the timer and to store different values in its instance variables, which you don't want to be affected by the saving/loading events.

    I have a global variable named TimeRemaining. I set the timer every second as below

    When I use a System action called "Save Game", it saves the value of the global variable. This happens when I reach a checkpoint. Now, for example, The game continues thereafter for 10 more seconds before player hits the obstacle. In this case I have to reset the game back to the checkpoint, so I use the system action "Load Game" and mention the slot to load. This leads to resetting all the variables including the "Time Remaining" global variable. I want to avoid resetting this variable.

    With your approach it will just save the state of the object but not the variable. Or am I doing something wrong?

  • Create an instance variable TimeRemaining on that object, and use it instead of the global variable.

    Or another method is to save the value of the global variable into the instance variable before saving. And then restore it from the instance variable in "On Load complete" event.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)