Query - Level Select with Local Storage

0 favourites
  • 10 posts
From the Asset Store
Basic Plugins for Firebase Authentication, Realtime-Database, Firestore, Cloud Storage
  • I have made a platformer game which is having multiple worlds and for that, I've put LevelSelect layout and the level select mechanism work pretty well the only issue is when I restart the app (android app) all the unclocked level got locked again. I have seen multiple tutorials suggesting to use the "Local Storage" but couldn't able to figure it out yet. So, I have made a small c3p. Please check out the file and help me.

    Thank you.

    https://drive.google.com/open?id=1K-uZaHvPX_MNsCfzFTsbVzvyUisLAjom

    The Google Drive link has been updated I accidentally added some extra events which wasn't needed at first place. Sorry for that.

  • Hiya. So for this you don't use local storage. When you save to the save slot on collision with a checkpoint it saves the state of the game including the array, so you can remove all local storage stuff. Your array logic is a little convoluted, it can be made simpler, just have the array set the location to 1 on the start of the stage and keep the logic consistent across the event sheets. When you go to 'continue' it will load the state of the game including the array values that are 1 therefore saving the level select. Also remember to clear the array to 0 when you select 'new game' or it is keeping array data from the game you were just playing.

  • Thanks for your input, pal.

    I want to retain both the continue button mechanism [The solution you gave in another post https://bit.ly/2KAGWrO] and the level select mechanism how could I mix both using the same save state. Could you please give any example capx/c3p or something? I really could not able to figure it out.

    Having said that I have made this WorldSelect using array by referencing a video from GameDev YT channel https://youtu.be/0M_kR6KehHY.

  • Have an array that stores what levels are unlocked, and save that to local storage. Then on game continue, load the array and the player should be able to continue progress from previous play.

  • The Google Drive link has been updated I accidentally added some extra events which wasn't needed at the first place this may the reason it was convoluted, Sorry about that.

  • Have an array that stores what levels are unlocked, and save that to local storage. Then on game continue, load the array and the player should be able to continue progress from previous play.

    Thanks to your input LukeW

    Yes, that's where I'm bit confused, How and where to add the array to save it with Local Storage as I wanted Continue button to work independently because it was for the checkpoint purpose.

    Thank you.

  • The way i do it in my game is that every time the succesfuly finishes the level and unlocks a new one, i first add all this new data to the Levels array, and after that is finished, i save the LevelsArray as JSON into my Local Storage. You load from LocalStorage when you start the game either on the Loader Layout or on your Main Menu.

    So you need:

    .-A LevelArray object, it stores the level data included if it is unlocked or not.

    .-Local Storage object, you save into this each time you know the player unlocked something. You save as JSON, for example LocalStorage set key "SaveGame" -> LevelArray.AsJSON

    .- On start of layout either on Loader Layout or Main Menu, you ask for LocalStorage "SaveGame" key.

    .- On Load Storage get key complete action -> LevelArray Load as JSON -> LocalStorage.ItemValue (this returns the last data you asked for, in this case the JSON)

    Hope this helps!

  • Thanks to your input LukeW

    Yes, that's where I'm bit confused, How and where to add the array to save it with Local Storage as I wanted Continue button to work independently because it was for the checkpoint purpose.

    Arrays are global in scope, so it doesn't matter which layout you add it to, it will be available across the project. Follow Sachos345's steps and it should work.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The way i do it in my game is that every time the succesfuly finishes the level and unlocks a new one, i first add all this new data to the Levels array, and after that is finished, i save the LevelsArray as JSON into my Local Storage. You load from LocalStorage when you start the game either on the Loader Layout or on your Main Menu.

    So you need:

    .-A LevelArray object, it stores the level data included if it is unlocked or not.

    .-Local Storage object, you save into this each time you know the player unlocked something. You save as JSON, for example LocalStorage set key "SaveGame" -> LevelArray.AsJSON

    .- On start of layout either on Loader Layout or Main Menu, you ask for LocalStorage "SaveGame" key.

    .- On Load Storage get key complete action -> LevelArray Load as JSON -> LocalStorage.ItemValue (this returns the last data you asked for, in this case the JSON)

    Hope this helps!

    Thank you very much sachos345, I finally able to pull it off. :)

  • > The way i do it in my game is that every time the succesfuly finishes the level and unlocks a new one, i first add all this new data to the Levels array, and after that is finished, i save the LevelsArray as JSON into my Local Storage. You load from LocalStorage when you start the game either on the Loader Layout or on your Main Menu.

    >

    > So you need:

    >

    > .-A LevelArray object, it stores the level data included if it is unlocked or not.

    >

    > .-Local Storage object, you save into this each time you know the player unlocked something. You save as JSON, for example LocalStorage set key "SaveGame" -> LevelArray.AsJSON

    >

    > .- On start of layout either on Loader Layout or Main Menu, you ask for LocalStorage "SaveGame" key.

    >

    > .- On Load Storage get key complete action -> LevelArray Load as JSON -> LocalStorage.ItemValue (this returns the last data you asked for, in this case the JSON)

    >

    > Hope this helps!

    Thank you very much sachos345, I finally able to pull it off. :)

    No problem dude, glad i could help =)

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