NaN for High Score

Just started using Construct 2? Post your questions here

Post » Wed Jul 20, 2016 5:24 am

What is the problem with the highScore variable? Everytime I tested the game on Chrome, the High Score will be NaN. Any solution? Below are the screenshots
Image
Image
Image
B
10
S
3
G
1
Posts: 12
Reputation: 1,008

Post » Wed Jul 20, 2016 6:12 am

Possibly on the last event make sure the value is an integer with int(LocalStorage.ItemValue)? Not quite sure... I imagine it IS getting something, otherwise the high score would remain at 0.

Or does it have the same problem with all the localstorage events disabled as well?

Edit: I don't see where you set the HighScoreText to HighScore anywhere... Maybe you're just not displaying the number? When you check in debug mode, does the highScore variable show the correct number? Reference capx: https://www.dropbox.com/s/m5u06uuk9fh78 ... .capx?dl=0
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Wed Jul 20, 2016 7:40 am

Message: BlackyDragon can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
I set the HighScoreText to highScore in Event sheet2 of Gameover layout. https://lh3.googleusercontent.com/-9duW ... 2event.jpg
Will it be affected?
What do you mean by the localstorage events disabled? Could you explain more about it? Thx
B
10
S
3
G
1
Posts: 12
Reputation: 1,008

Post » Wed Jul 20, 2016 8:15 am

Look in the debugger at LocalStorage. You should see its contents.

Is it full of jibber from previous projects or from versions of this project ?

Then add keyboard. Assign a key > action > LocalStorage > Clear Storage.

Run the project. (project, not layout) Press the key. Quit browser. Try again.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Jul 20, 2016 9:36 am

@99Instances2Go Yeay. It works. Thanks :D

Oh.. What is the difference between Run Layout and Run Project?
B
10
S
3
G
1
Posts: 12
Reputation: 1,008

Post » Wed Jul 20, 2016 10:18 am

BlackyDragon wrote:@99Instances2Go Yeay. It works. Thanks :D

Oh.. What is the difference between Run Layout and Run Project?



If you had multiple Layouts in your project, then selecting 'Run Layout' would run the currently selected Layout, such as Level 5 of your game.

'Run project' would run your project from the Layout stated in the Project Settings option of the Project Properties, usually set to 'Default', i.e. the first Layout of your project.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,387
Reputation: 58,456

Post » Wed Jul 20, 2016 10:36 am

zenox98 wrote:
If you had multiple Layouts in your project, then selecting 'Run Layout' would run the currently selected Layout, such as Level 5 of your game.

'Run project' would run your project from the Layout stated in the Project Settings option of the Project Properties, usually set to 'Default', i.e. the first Layout of your project.

Ok. Thank you for the information :)
B
10
S
3
G
1
Posts: 12
Reputation: 1,008

Post » Wed Jul 20, 2016 10:59 am

Well i dont see your capx, have no idea how many layouts & associated event sheets you have, no idea if you store and retreive in differend sheets ...... so i 'played' on save.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Jul 20, 2016 2:45 pm

99Instances2Go wrote:Well i dont see your capx, have no idea how many layouts & associated event sheets you have, no idea if you store and retreive in differend sheets ...... so i 'played' on save.

Beginner's Question ;)
Thanks much for your help by the way :)
B
10
S
3
G
1
Posts: 12
Reputation: 1,008

Post » Sat Jul 23, 2016 5:57 am

I made this tutorial its easier to follow

https://www.scirra.com/tutorials/5343/h ... -game-capx
Check out my awesome Android Game releases https://play.google.com/store/apps/deve ... ames&hl=en
B
38
S
18
G
24
Posts: 681
Reputation: 16,613


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest