Keep Score between layouts

Get help using Construct 2

Post » Thu Nov 21, 2013 9:38 am

Hi

How can I keep my global Score value going from layout to layout
since global are reset.. on new layout


I see that the NEW r151


has a new feature:

New common expression 'AsJSON' and common action 'Set from JSON'. These allow you to take advantage of the savegame system to save and load individual instance states without having to save or load the entire game, as well as other useful things like setting one object's state to another's.





Regards
flemming

New r151flemmig2013-11-21 09:43:46
B
33
S
17
G
11
Posts: 350
Reputation: 8,695

Post » Thu Nov 21, 2013 9:40 am

I thought global variables are only reset if you have an event to reset them?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Nov 21, 2013 9:47 am

Global variables aren't reset between layouts. That's entirely the point of them.

flemmig, I can only think that you're either deliberately resetting them with an event, or you're accidentally using local variables.

EDIT: Just saw your reply now. I'd suggest that, if you need to reset global variables often, you use WebStorage or Dictionary to store your score.GeometriX2013-11-21 09:48:46
B
57
S
15
G
11
Posts: 912
Reputation: 12,626

Post » Thu Nov 21, 2013 9:47 am

Yes I have alot global values I reset on each layout start

I guess I could use a local value for the Score but its easier
to use the global through all events -

Or maybe somehow save to webstorage and load the Score after my
included eventsheet in where i reset the globals

Tried this



flemmig2013-11-21 09:56:28
B
33
S
17
G
11
Posts: 350
Reputation: 8,695

Post » Thu Nov 21, 2013 9:49 am

So actually your throwing something away that you want to keep?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Nov 21, 2013 9:51 am

If you have a lot of global variables already it wouldn't hurt to make one more for the global score that you don't reset.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Nov 21, 2013 10:04 am

Yes @LittleStain

But how is that done .. In each layout I include a Core eventsheet
that holds the

On start of layout > system reset global variables to default

B
33
S
17
G
11
Posts: 350
Reputation: 8,695

Post » Thu Nov 21, 2013 10:16 am

Would using a global object to get the variable from one layout to the other work?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Nov 21, 2013 10:37 am

Hmm ..
since it is global it is reset by system reset global variables to default

So Im back to how to avoid it being reset, dont you think..
If I could figure out how to save the Score value and load it after the reset..




B
33
S
17
G
11
Posts: 350
Reputation: 8,695

Post » Thu Nov 21, 2013 10:46 am

Did you read my last post?

I'm talking about adding an instance variable to a global object or setting the value in a global array and retrieving it after resetting the global variables.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 16 guests