0 Favourites

Save Issue

  • I am trying to understand the logic behind Webstorage. I want to use it to save my game on an android device.

    Basically I have a global score, that I set it to text, then I make the text show up on a category page.. So if there are 10 levels in the game, I want to show you the score you received on each level played. I am having no luck. I saw a lot of save tutorials, but its does not seem to be working for me. Can someone help me out pls. thx

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • The logic will generally look something like this, just to make sure that you've got it down right:

    1) Player completes level X and sets a score, let's call it a global variable LevelScore.

    2) Compare score to currently saved high score (compare as a number), called WSLevelXScore or whatever.

    3) If the current score is higher, set WSLevelXScore to LevelScore.

    4) Then you set your text objects on the level select screen.

    The last bit is tricky, because it requires that you set each text object individually. You could create ten different text objects, but its much easier to create one and clone it nine times. Each time you clone it, you're adding 1 to its IID (instance ID, starting from 0). So to set the scores to each of them, do something like this:

    System : On Start of Layout, Repeat 10 times, Pick nth instance (ScoreText)(loopindex) -> Set ScoreText Text to WebStorage.LocalValue("WSLevel"&loopindex+1&"LevelScore").

    I've attached a quick example of the last bit.

  • Save for mobile is kinda easy. SAVE on the layout you want, then use the LOAD on the layout the player will open the app to. Hit me if this confusing.

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