Saving game position when game is closed

0 favourites
  • 6 posts
From the Asset Store
Match the similar cards with each other and free all animals!
  • Hi, I'm quite new to Construct and have recently made a game. One complaint I've had constantly is that it doesn't save when the game is closed! Basically I've looked at how to save variables using LocalStorage (which seems like a lot of work because it's quite a big game) and looked somewhat into arrays and I'm just curious if there is a simple(ish) way to go about having the game load to exactly where it left off before it closed.

  • JesseJames11 - What are you trying to accomplish? If you are trying to save a game state and later loaded by the player then you can use the system action (Save)

    System --> Save --> Slot("Save Name")

    If you are trying to save values like coins then you can use the localstorage. Arrays works like variables but comes with three values per row (X, Y, Z) unlike variables which only has X per variable, and arrays are not saved on close of app. But array values can be downloaded to the LocalStorage so that it can be saved even when app is closed and loaded afterwards whenever you want to, like "on game start up" or "start of layout".

    In conclusion,

    If you want to save game state:

    System --> Save --> Slot("Save Name")

    If you want to save game values:

    Storage:-------Persist on close of app:---Can be set on LocalStorage:

    Local Storage:----------Yes-------------------------(Yours truly)

    Dictionary:--------------No----------------------------Yes

    Array:---------------------No----------------------------Yes

    Local/Global/

    Instance Variables:--No----------------------------Yes

  • Wow. How did I not see the save function? Will this save every purchase made, money, sprite position, etc. until loaded again?

  • JesseJames11 - The Save Action saves almost all : Arrays, Local/Global/Instance Variables, Sprite Positions, Size and Etc. , Dictionaries,

    Except:

    The LocalStorage(previously called WebStorage) is not saved since it already persists even when closed, so this is an independent storage.

    -Input state (i.e. mouse position, or whether the player was holding keys or touches)

    • AJAX requests
    • WebSocket connections
    • The XML object
    • User Media video or audio feeds
    • Facebook login
    • (WebStorage/LocalStorage!!!! state)
    • CocoonJS/Windows 8 state
    • Any in-app purchases on any platform
    • Anything with the 'No Save' behavior)

    More information:

    https://www.scirra.com/tutorials/526/ho ... -savegames

  • I tried this and have run into a problem. I have it set to:

    Every X Seconds - Save Game "mysave"

    Start of layout - Load game "mysave"

    which works fine if I close and re open the game. But then if I do it a 2nd time it doesn't load.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I tried this and have run into a problem. I have it set to:

    Every X Seconds - Save Game "mysave"

    Start of layout - Load game "mysave"

    which works fine if I close and re open the game. But then if I do it a 2nd time it doesn't load.

    I think you misunderstood the use of Save() :

    Save() is not something you use to save changes what the player did on your game ex, for every 2 seconds since it will be too hard for it saves almost everything in your game.

    In your situation, if you are saving for ex. money, coins or anything that is a value. You should use the localstorage. Please refer to the table above.

    -Edit

    Save() is for example, for RPG- Games that you save your gameplay state from where you left off. Since it saves almost everything, then it would be too inconvenient to add a time interval lesser than 30 seconds for (every X seconds) to save the gamestate. Besides, while saving it will pause momentarily depending on the write speed of the Device.

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