Can't remember data after loading?

Discussion and feedback on Construct 2

Post » Mon Jul 15, 2013 10:54 pm

I've hit an interesting problem.

I'm using a checkpoint system which involves using the 'save' and 'load' system actions. Basically, whenever you hit the checkpoint, the game saves, and whenever you die, the game loads.

I'm trying to have a variable called 'RespawnTime' which records the amount of time since the last respawn. As such, it should set to zero on death.

The problem is, global variables are reset to their previous value after a 'load' action, meaning it seems like there's no way to save any data or do anything when loading!

Here's an example capx to show what I mean. If you hit the checkpoint then die, you respawn correctly. However, it seems as if the 'Set RespawnTime to 0' action in event 11 didn't do anything!

Am I foolishly forgetting something, or is this indeed the interesting conundrum I think it to be?
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Post » Mon Jul 15, 2013 11:02 pm

Better off with dictionaries & webstorage :B
Image
B
242
S
29
G
13
Posts: 1,787
Reputation: 18,685

Post » Mon Jul 15, 2013 11:09 pm

@Tokinsom

Webstorage might work with the no save behavior.
Image ImageImage
B
168
S
50
G
163
Posts: 8,224
Reputation: 105,067

Post » Mon Jul 15, 2013 11:41 pm

I meant not using the save feature at all ^^;
Image
B
242
S
29
G
13
Posts: 1,787
Reputation: 18,685

Post » Tue Jul 16, 2013 12:40 pm

The 'Load' action can take a few ticks to complete. Anything done between the 'Load' action and the 'On load completed' trigger firing will probably be replaced by loading the game. You probably wanted to put that action in 'On load completed'.
Scirra Founder
B
387
S
230
G
87
Posts: 24,249
Reputation: 192,240

Post » Tue Jul 16, 2013 3:46 pm

Yes, I tried it, it works well after added an event 'On load complete' included an action 'Set Respawn Time to 0'.

I think it means anything you want to do in game loading process, you should put it in 'On load complete' trigger event which followed 'Load' action, is that right?KennyOops2013-07-16 15:47:57
B
37
S
4
G
2
Posts: 45
Reputation: 3,997

Post » Tue Jul 16, 2013 4:06 pm

Yep, I can confirm that 'On Load Complete' definitely works.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 10 guests