Unlock levels by global variables

0 favourites
  • 5 posts
From the Asset Store
Globals 2.0
$3.60 USD
10% off
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • Hi, I want to unlock the levels of my game by the global variables and save this by webstorage. But the webstorage can't work. How can I do this??

    I tried this:

    (except level 1, the other levels have a global variable: level2, level3... whit initial value 0)

    On end of layout(level 1) --> set level2 to 1

                                 set local key "lev2save" to "level2"

    And in the event sheet of levels:

    if level2 is=1

    on touch object     --->go to level 2

    On start of layout ---> Set level2 to Webstorage.localvalue("lev2save")

    Now, if i deactive this (On start of layout ---> Set level2 to Webstorage.localvalue("lev2save")) level unlock work, if this is active the level remains locked (or unclickable), so I think I'm wrong on the condition for save the level unlocked, right? Maybe I need another condition to save the variable??

    Please help!

  • GAMEGAMEGAME cesisco made a nice example .capx on how do this maybe it will help:

    Webstorage multilevel saving

  • Ok thank, I try this.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • seems that work. But if it run on a mobile device, maybe by appmobi, how the game save? I know that webstorage use cookies of browser, so in a "native" app for mobile, it use the mobile browser or? can someone explain?

  • I haven't tried appMobi in a while I'm still waiting for them to get direct canvas working with Android but this method should work with appMobi. I have used it with CocoonJS, and it works good.

    WebStorage will save whatever you tell it to inside of the mobile devises default browser. I usually, add a reset game option someplace in my game so people can erase all the webstorage data, and start over fresh if they want to.

    You can do this by creating a image button representing a restart symbol. then give it a on touched object event, and then a clear local storage action.

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