How do I save position of sprite in webstorage

Get help using Construct 2

Post » Mon Apr 29, 2013 9:12 pm

Hi,
How can I save position of sprite in webstorage, is it possible? So it's in the same place when user comes back to the game, until he or she movies it again.
B
7
S
1
G
3
Posts: 27
Reputation: 2,169

Post » Mon Apr 29, 2013 9:27 pm

[QUOTE=roke] Hi,
How can I save position of sprite in webstorage, is it possible? So it's in the same place when user comes back to the game, until he or she movies it again.[/QUOTE]

You have to set 2 keys: "PlayerX" and "PlayerY" for exemple, in the local storage, set to the player X and Y respectively

then when you load the game (conditions of your choice, a button maybe), you begin the layout, and at the start, you set the X of the player equal to int(WebStorage.LocalValue("PlayerX")), and for the Y, the same but with the Y

the manual should help you too:

Webstorage
https://www.scirra.com/forum/viewtopic.php?t=152506

And that is why you shall respect the bug reports guidelines, not only giving a capx is making the bug reproductible in one click in a situation they can work with (less time wasted trying to reproduce vague instructions) but also it helps filtering false positives.

Game design is all about decomposing the core of your game so it becomes simple instructions.
B
42
S
17
G
16
Posts: 2,094
Reputation: 15,355

Post » Sun May 05, 2013 7:24 pm

Thank you, I got it somehow working = )
B
7
S
1
G
3
Posts: 27
Reputation: 2,169

Post » Mon May 06, 2013 12:18 am

Theres the new saving feature that will probably be a lot easier.
B
40
S
12
G
7
Posts: 603
Reputation: 7,656

Post » Mon May 06, 2013 2:09 pm

Thanks about that too, that new feature looks good.
B
7
S
1
G
3
Posts: 27
Reputation: 2,169


Return to How do I....?

Who is online

Users browsing this forum: GSquadron, jeffige, MarkThomas, MisterAqua, paala, Waltuo and 18 guests