How do save/load between différent scene without bug ?

0 favourites
  • 15 posts
From the Asset Store
Template for a generic save / load system, fully documented in comments and video
  • Hello, I have a problem saving and loading my game.

    When I save and reload on the same scene, I have no problem, all the elements are displayed correctly.

    However, when I change scenes with a save in the game and I return to the menu, then I load the save, there are elements that are no longer displayed. I have to spam the loading of the same save several times to have the correct scene memorized.

    In addition, there are many times after this manipulation, the game crashes (black or frozen screen).

    This bug is also the same when I exit and restart the project window.

    Do you have any ideas ?

    Thank you very much for your feedback.

  • This save game feature is very troublesome, never use it.

    Use Local Storage to save and load, there are many examples to learn from.

  • Hi, sorry for the late response.

    I watched tutorials on local storage, json, ajax, dictonary, etc. It seems really complicated for a non-expert like me (that's why I chose Construct which seemed much easier to use).

    My project has a lot of data to back up and I don't know how I'm going to get through it. Is there no other way to retrieve all game data at a moment's notice and reload it?

    Thanks again for your feedback

  • Unfortunately the save game feature is... let's say "special" because it works fine until it doesn't. But the best way to tackle this currently is local storage. It isn't as complicated as it may seem and you only need to learn it once and then you can use it forever :)

    Here's a basic setup to get you started

    wackytoaster.at/parachute/basicSavegameSetup.c3p

  • Tell us what you want to store, whether local variables or an array or a dictionary, and we'll show you an example.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi guys,

    Thanks for your feedback.

    I understood the idea a little more thanks to the basic savegame project.

    However, I have objects that have several variables to enter

    For example :

    A square on a grid, I need to retrieve the following information:

    - the level of the square

    - the type of the square

    - the square experience

    - the position (X and Y) of the square

    I understood that we could use the array but I'm a little stuck here ><

    Thank you again for your help

  • I'm assuming your square is a sprite?

    You can also save an entire Sprites data by accessing it with Sprite.asJson. So instead of taking individual variables, you can just save the entire Sprite. And of course load it too.

  • Yes this is a sprite.

    But i have many instance of them. And i have other like circle, etc.

    How do i take all instances of (for exemple) many square and many circle AND after the load, all sprite have the right position, type, xp, lvl, etc.

    Thank by advance !

  • You can put dictionary.asJson into yet another dictionary. So you could have one dictionary "savegame" and one dictionary for each type of sprite like "circles", "squares",...

    On save you loop through all sprites and put them into the "circles" dictionary. Then you put "circles.asJson" into the "savegame" dictionary under the "circles" key.

    When you load, you first load the JSON into the "savegame" dictionary, then you take the "circles" key and load it into the "circles" dictionary via savegame.Get("circles")

    Finally you loop through all keys in the "circles" dictionary and create a sprite for each and load the saved data into them.

  • Hi !

    Thank you very much WackyToaster !

    That work for for the "circle" (sprite).

    But when i use families with differents sprites, that doing so much bug. Random sprite, random position, random size, etc.

    I need to do 1 sprite by 1 sprite to save ?

    Thank again

  • Hi !

    Thank you very much WackyToaster !

    That work for for the "circle" (sprite).

    But when i use families with differents sprites, that doing so much bug. Random sprite, random position, random size, etc.

    I need to do 1 sprite by 1 sprite to save ?

    Thank again

    Can you give a small example with a square and a circle, I'll add a local save and load there.

  • Hi igortyhon !

    Here an exemple :

    exemple c3p format : we.tl/t-vWduyT9UCv

  • Families are a bit tricky. If you tell Construct to create an object "Family" it will randomly pick one of the objects assigned to that family. So if your family contains cirlces and squares, this will randomly create a circle or a square. You probably need to store the name of the object and then "create object by name"

    But without knowing exactly how your project is set up it's hard to give definitive answers on how to solve X, so ideally you could just post an example of your setup.

  • You ninjad me :)

    It was as I suspected the issue with creating families. The solution is simply to also store the objects name inside the key. And then extract the name using tokenat (the alternative would be using an array) construct.net/en/make-games/manuals/construct-3/system-reference/system-expressions

    and create the object based on the name. You then have to pick the last created family and load the data.

  • °-°

    You are a wizard WackyToaster !

    Thank you very much, it's work very well ! Whaow ! Thank !

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