How do I Take Care Of 'NaN' Thingy When I Load My Game!

Get help using Construct 2

Post » Sun Mar 02, 2014 10:42 am

I Have Made A Feature Of Save/Load Which Also Loads Global Variables Like Score, Health Etc! But When I Play My Game On A System Where I Have Never Saved My Game (Cookie), I Get A Text 'NaN' In The Place Where Score/Health Should Be! How To Prevent/ Take Care Of That!? Please Help! :roll: :? :|
B
7
S
2
G
1
Posts: 17
Reputation: 1,336

Post » Sun Mar 02, 2014 12:13 pm

You should check on every start of the game, if the game was played on this device before. If not, set the variables to default values.
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Mon Mar 03, 2014 3:55 am

Rabenmutter wrote:You should check on every start of the game, if the game was played on this device before. If not, set the variables to default values.


And How Can I Do That? :roll:
B
7
S
2
G
1
Posts: 17
Reputation: 1,336

Post » Mon Mar 03, 2014 6:19 am

How exactly do you save your variable? WebStorage?
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Mon Mar 03, 2014 8:02 am

NaN = Not a Number
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Mon Mar 03, 2014 8:05 am

Here is an example i did for someone else saving coins.
Example:
It check if it exists, if it does then load it.
It save it automatically as global variable changes,
It loads when user returns to game,
It has a reset button lol

I did it quick, but it shows the process.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Tue Mar 04, 2014 6:19 pm

Rabenmutter wrote:How exactly do you save your variable? WebStorage?


Yeah! Webstorage Does That For Me! :P
B
7
S
2
G
1
Posts: 17
Reputation: 1,336

Post » Tue Mar 04, 2014 6:22 pm

lennaert wrote:NaN = Not a Number


Oh! Thanks Bro!
B
7
S
2
G
1
Posts: 17
Reputation: 1,336

Post » Tue Mar 04, 2014 6:24 pm

DUTOIT wrote:Here is an example i did for someone else saving coins.
Example:
It check if it exists, if it does then load it.
It save it automatically as global variable changes,
It loads when user returns to game,
It has a reset button lol

I did it quick, but it shows the process.



Thanks Bro! You Rock! :P :) That Did It For Me! Thanks Again! :lol: 8-)
B
7
S
2
G
1
Posts: 17
Reputation: 1,336


Return to How do I....?

Who is online

Users browsing this forum: unxcellent, Yahoo [Bot] and 10 guests