keep value of global variable after moving to another layout

0 favourites
  • 5 posts
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.
  • I have a global variable (level) which is increased by one if the global variable (win) equal 1, so that after the player win he can go to the level selection layout and find level 2 opened,

    and what I need is to make the global variable (level) keep the value 1 when I go to another layout

    it worked fine with me, the global variable (level) kept its value when I used the action go to layout_level_selection inside the win = 1 condition like this:

    but when I added the action go to layout_level_selection inside inside a button which will show when the player wins, the global variable (level) value reset to zero, like this:

  • This won't do what you want anyway. Event 5 will trigger every tick constantly adding 1 to level until a button is pressed. Move your touch events into a Group and in event 5, set win=0, and enable your new group. Disable the group in On start of layout.

    This still doesn't explain why level is reset to 0, it should be some large number, due to the tick issue. We'd need to see more to comment further.

  • I saved the global variable (level) using webstorge and load it in the level selection layout and

    I realized that value doesn't reset to zero but it increase to 48 instead of 1

  • Which makes more sense with what I expected. So reread my suggestion on how to fix this.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah, blackhornet is right, event 5 just keeps running and adding to the level every tick, UNTIL one of those things is touched.

    Try making it make win =2, then use a new statement to check if win=2, then if it does, do the touch stuff after that.

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