Saving game position when game is closed

Get help using Construct 2

Post » Fri Mar 04, 2016 12:14 pm

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.
B
16
S
2
Posts: 26
Reputation: 794

Post » Fri Mar 04, 2016 12:24 pm

@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
Last edited by chadorireborn on Fri Mar 04, 2016 12:35 pm, edited 2 times in total.
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
65
S
21
G
90
Posts: 1,124
Reputation: 59,852

Post » Fri Mar 04, 2016 12:32 pm

Wow. How did I not see the save function? Will this save every purchase made, money, sprite position, etc. until loaded again?
Last edited by JesseJames11 on Fri Mar 04, 2016 12:43 pm, edited 2 times in total.
B
16
S
2
Posts: 26
Reputation: 794

Post » Fri Mar 04, 2016 12:41 pm

@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
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
65
S
21
G
90
Posts: 1,124
Reputation: 59,852

Post » Fri Mar 04, 2016 12:43 pm

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.
B
16
S
2
Posts: 26
Reputation: 794

Post » Fri Mar 04, 2016 12:48 pm

JesseJames11 wrote: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.
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
65
S
21
G
90
Posts: 1,124
Reputation: 59,852


Return to How do I....?

Who is online

Users browsing this forum: adventurist, Blendi1223, PROxMTswatTR, Yahoo [Bot] and 34 guests