[Solved] How do I use save/load in r124?

Get help using Construct 2

Post » Wed Apr 03, 2013 5:36 am

[r124]
I put 1 sprite, save, destroy it, load. But no sprite created.

How do I use save/load?

Ans:

- save

+ on save complete
- destroy
- loadrexrainbow2013-04-03 06:10:28
B
97
S
22
G
178
Posts: 4,118
Reputation: 104,043

Post » Wed Apr 03, 2013 5:56 am

I would try putting some ticks between or something... then again, I haven't touched it yet so I may just be talking out my hoohaa... No manual entry for it yet?
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418

Post » Wed Apr 03, 2013 6:03 am

@BluePhaze

I'm waiting an example, too.

I put a wait 1 sec action before load, but still no sprite created.
B
97
S
22
G
178
Posts: 4,118
Reputation: 104,043

Post » Wed Apr 03, 2013 6:05 am

Odd, maybe it is a next top level event needs to fire first type of thing for the save to finish? Maybe try with a couple of buttons one to save with its own event, and one to load? I will through some test together in a few minutes to see what happens...
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418

Post » Wed Apr 03, 2013 6:07 am

@BluePhaze

Yes, I find the missing condition, thanks.
B
97
S
22
G
178
Posts: 4,118
Reputation: 104,043

Post » Wed Apr 03, 2013 6:20 am

I got it working, I made a simple capx with 3 sprites, clicking on one of them saves, clicking on another loads. Clicking the third one moves it 10 pixels at a time. So I move it a bit, then save, then reload the layout, then load and it goes back to where it was when I saved it. Now I just need to find a way to save to a remote location in case I want to allow saved games to be used between multiple devices by the users...
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418

Post » Wed Apr 03, 2013 6:38 am

The interesting thing is -- the uid will not be increased after loading. Old instances will be changed by loading info.rexrainbow2013-04-03 06:38:42
B
97
S
22
G
178
Posts: 4,118
Reputation: 104,043

Post » Wed Apr 03, 2013 6:51 am

The UIDs are probably saved as well. If you have the UID of an object in a variable, the reloaded object has to have that same UID for the variable to have the right one.
B
200
S
51
G
30
Posts: 897
Reputation: 36,496

Post » Wed Apr 03, 2013 7:22 am

Another one to watch out for, if you save a game, then an update gets pushed out for the game, then you load the updated game and have it load the saved state, you may get some oddities because the old state of the objects is loaded. For example, I saved the game state, then added some new UI components and moved some of the old UI components, did the rebuild and ran the update version, hit my load save game button, and the new UI components still showed, but the old ones jumped back to their old spot which caused a good deal of oddness in the HUD/UI layer. Just one thing to be cognizant of, the old state of objects saved does not take into account new objects which makes perfect sense, but I can also see a lot of designer getting into trouble with pushing game updates to games that support the save state features...
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418

Post » Wed Apr 03, 2013 2:53 pm

Save is asynchronous and hasn't completed until 'On save complete'. So if you do Save and Destroy Sprite in one event, the destroy will actually happen before the save and therefore get saved with it.

Also note UIDs are saved as well, so when loading objects restore with the same UIDs they had at the time of the save. (Otherwise lots of games would be broken!)
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Next

Return to How do I....?

Who is online

Users browsing this forum: flemmig, Jarnopa, nimos100, semaso, Skebab and 11 guests