Reset global variables? (Possibly more)

This forum is currently in read-only mode.
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Hello everybody,

    I am new to the whole construct-thing but I'm having loads of fun making my game and have already had quite some succes doing so.

    However now I can't seem to find an option to reset gvars. What i basically want to do:

    Player's spaceship dies once its gvar 'Shields' reches zero or below. Game switches to game over screen, now when I press the 'Resume' button I'd like the gvar 'SHields' to be reset to its initial value. Is there a way to do this?

    And if there is: Is there a way to alter a gvar's default value too?

    Situation: Starting Shield gvar is 4. Player buys upgrade for his shields, so gvar should be defaulted to 5 and after game over it needs to reset to 5 as opposed to 4 now.

    I hope people can decipher what I mean. <img src="smileys/smiley5.gif" border="0" align="middle" />

    Thanks in advance for any help!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Global variables remain the same between layouts, so if it goes up to 5 it will stay that way as long as the game is open, or you use a "Set global variable" action to change it.

    However, the default value only applys when the program first starts. So no, chaning the default value of a global variable is not possible.

    You could just try having another global variable called "defaultshield" and then on the start of layout set "shield" to "defaultshield". Then you just increase defaultshield to 5 as well as shield.

  • Thanks alot. That solution seems simple but it works perfectly. Guess sometimes you don't see the most practical things too quickly. <img src="smileys/smiley4.gif" border="0" align="middle" />

  • Thanks alot. That solution seems simple but it works perfectly. Guess sometimes you don't see the most practical things too quickly. <img src="smileys/smiley4.gif" border="0" align="middle" />

    No problem, glad it's working out <img src="smileys/smiley1.gif" border="0" align="middle" />

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