How do I save a high score?

Get help using Construct 2

Post » Mon Mar 27, 2017 10:44 pm

You're missing quite a few steps. Read the manual entry, follow the tutorial. Localstorage is asynchronous - that means it doesn't run in the same time as your event sheet.

For example here is a flow to read the value of the key "score":

Use the action Get item "score"
A moment later, On item "score" get triggers
In this trigger, use the ItemValue expression to read the item
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Mon Mar 27, 2017 10:55 pm

Message: jakeedge02 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
its just stays zero now

Edit: also all the other steps are at another layout the picture is layout 3 and the other steps are at layout 1

Edit 2: this is layout 1
http://fav.me/db3rhhf
B
6
S
1
Posts: 36
Reputation: 424

Post » Mon Mar 27, 2017 11:15 pm

On the second layout, you will need to once again check if key exists, then set your variable in an "On exists" event.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Mon Mar 27, 2017 11:30 pm

Ugh im struggling to understand but i put the local storage check which checks if PlayerHscore exists can you please explain to this noob on what do you mean on what variables should i add? its probably something stupid that im missing or forgetting..
B
6
S
1
Posts: 36
Reputation: 424

Post » Tue Mar 28, 2017 12:28 am

maybe its one of the events i used do you want me to send an image of all the ones i used? I just done know whats wrong the examples you linked worked fine
B
6
S
1
Posts: 36
Reputation: 424

Post » Tue Mar 28, 2017 3:53 am

Ok I have no idea what is going on with all the layouts and event sheets but you have no "Get Item" action anywhere. Localstorage.ItemValue is nothing until you get an item, and put it in an event with an "On Item Get" condition.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Tue Mar 28, 2017 7:05 am

I hate the "High Score" it's a little bit confusing hope this example I did will help you :) Good Luck

VVVVVV
VVVV
VV
V

https://drive.google.com/open?id=0BxA-Jhyy5p-GeTFBNkZya0RDbUk
B
24
S
9
G
8
Posts: 49
Reputation: 6,080

Post » Tue Mar 28, 2017 9:08 am

@alajajm
Itried that aswell but it still becoming NaN why!? all examples are ok is it my construct 2 problem or it it one ov the conditions i used...

@oosyrag
How come the examples i got has no get condition but it still worked?
B
6
S
1
Posts: 36
Reputation: 424

Post » Tue Mar 28, 2017 10:12 am

jakeedge02 wrote:@alajajm
Itried that aswell but it still becoming NaN why!? all examples are ok is it my construct 2 problem or it it one ov the conditions i used...


Hmmmm? Not sure it's working fine with me. Anyhow looking at your pic: http://fav.me/db3rhhf

First for the event ( One item "PlayerHScore" exists ) Set a HighScore Text to a value variable of PlayerHScore. This only if you want to show the highscore while the game on play

Second Move the whole event of ( PlayerScore > PlayerHScore ) under event of the group GameOver. So highscore update when the player loose.

Let Hope this work :)
B
24
S
9
G
8
Posts: 49
Reputation: 6,080

Post » Tue Mar 28, 2017 10:19 am

Message: jakeedge02 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
i tested it again on a new project and its the same it bcomes NaN


http://www.mediafire.com/file
/slbabs35exi8liw/New_folder_%283%29.rar

this is the test project can you guys test it aswell so that i would know if its something to do with my comp or something im missing?

Edit1: also made the PlayerHscore to Int(LocalStorage.iItemValue) <---- i added the int it shows now but iy skips the the game entirely and goes to game over with the same scores
Last edited by jakeedge02 on Tue Mar 28, 2017 10:37 am, edited 3 times in total.
B
6
S
1
Posts: 36
Reputation: 424

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: datiel12, tarek2 and 62 guests