Saveable game

Get help using Construct 2

Post » Sat Dec 31, 2011 5:09 pm

Hey people! Well, i wanted to know if there's a way to make a saveable game, so that the player can close the game and play from where he stopped (or a checkpoint). If it's possible, how to do it?
B
27
S
7
G
6
Posts: 34
Reputation: 4,881

Post » Sat Dec 31, 2011 5:21 pm

yes, but it's complicated
you could store values into "webstorage," which will store data locally, but if user clears cache, it's gone.
or you could use AJAX to connect to a server and store values on a server but that's more complicated...
B
29
S
5
G
6
Posts: 58
Reputation: 5,121

Post » Sat Dec 31, 2011 5:22 pm

Its pretty doable, Look at the local storage object.

You save local keys,

For example the players last x and y position, then on load button clicked load that key.
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Post » Sat Dec 31, 2011 5:30 pm

If you do as i did , your game won't be compatible with the arcade , also be sure to know that there is only 1 global checkpoint object , just copy this object and place the checkpoint as you want , and be sure to place them in order of copy

You can do it with the webstorage plugin ( set LocalVariables )
but..
They have to save by clicking on a button
Legend:S.C.= Webstorage Local Variable "SavedCheckpoint"
example:
---On Exit Clicked : Set (Webstorage Local Variable "SavedCheckpoint") to LastCheckpoint
---On Checkpoint Touched by Player :
-----------Pick instance 0 (First checkpoint) : Set LastCheckpoint to 1
--- On PlayObject (Main-menu Play ) clicked :Set LastCheckpoint to S.C.
---------- If LastCheckpoint = 1 :
---------------Pick instance 0
---------------------------------- Spawn Player on Checkpoint

Here ya go
Note: if you dont understand anything just post the capx , i will help you edit it
Also repeat this for all checkpoints
(example for Checkpoint 2)
-----------Pick instance 1 (add 1 for each checkpoint) : Set LastCheckpoint to 2 (add 1 for each checkpoints)
---------- If LastCheckpoint = 2 :(add 1 for each checkpoint)
---------------Pick instance 1 (add one for each checkpoint)
---------------------------------- Spawn Player on Checkpoint
kbdmaster2011-12-31 17:43:43
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Sat Dec 31, 2011 5:51 pm

Thank you all!
Still i would apreciate if someone could tell me how to make the save with the Local Storage object, to save the Player.X and Player.Y in a checkpoint, and how to load it.
B
27
S
7
G
6
Posts: 34
Reputation: 4,881

Post » Sat Dec 31, 2011 8:15 pm

Extract from the how do I FAQ:

Webstorage


    Save variables/example of use - LINK
    Other example of use of webstorage - LINK
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Sat Dec 31, 2011 9:13 pm

Thank you!
It worked! :D
B
27
S
7
G
6
Posts: 34
Reputation: 4,881

Post » Sat Dec 31, 2011 9:23 pm

Well i copied and pasted the events in my project, but if i try to make it by myself, i get NaN instead of the value :S
B
27
S
7
G
6
Posts: 34
Reputation: 4,881

Post » Sat Dec 31, 2011 9:30 pm

What source project are you talking about ? kbdmaster's ?

Also be sure to check the webstorage reference in the manual to understand more about how to use the webstorage plugin.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Sat Dec 31, 2011 9:36 pm

I copied the events from tonycrew's project LINK and it worked, but if i try to chose the events by my own, i get this error :S
B
27
S
7
G
6
Posts: 34
Reputation: 4,881

Next

Return to How do I....?

Who is online

Users browsing this forum: R0J0hound and 20 guests