How do I Associate 3 Letter Names with High scores

Get help using Construct 2

Post » Mon Apr 11, 2016 7:24 am

So Following a tutorial I found I managed to set up local storage and an array. I also Have implemented a way for the user to select three letters for their name, akin to old arcade games.

So now I need a way to associate each name with their respective score.

I would imagine I need to increase the array to a height of 2. But at that point I'm lost I don't know how to make sure the name stays with their respective score.

http://i.imgur.com/GvWXRUG.png
B
9
S
4
G
2
Posts: 39
Reputation: 1,805

Post » Mon Apr 11, 2016 8:13 am

2 things comments i like to give.

1/
Localstorage needs time to upload en download things. You can use downloaded data AFTER they are downloaded. Not during or so. Meaning: after a 'get item' you need a condition 'on get complete'. Then you can use the data.

I am sure that step was also in the tut. Look for it.

2/

You can simplify the whole thing by using a dictionary. Store the username in a key (check first for existing). Store de score in the value that goes with the key. Easy to handle. Easy to debug, the contents of the dictionary show in the debugger. And they always wil be a not seperatable pair.

Now, instead of adding a million keys to the local storage, you add just 1 key to it, give it a name you like, and store the json of the dictionary in its value.

You can ofcourse also write the array you use the same way in the local storage. (1 key, 1 value as json) But the array is in your case (only 1 text + just 1 number) just that little to complicated for what it is.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Apr 11, 2016 8:16 am

99Instances2Go wrote:2 things comments i like to give.

1/
Localstorage needs time to upload en download things. You can use downloaded data AFTER they are downloaded. Not during or so. Meaning: after a 'get item' you need a condition 'on get complete'. Then you can use the data.

I am sure that step was also in the tut. Look for it.

2/

You can simplify the whole thing by using a dictionary. Store the username in a key (check first for existing). Store de score in the value that goes with the key. Easy to handle. Easy to debug, the contents of the dictionary show in the debugger. And they always wil be a not seperatable pair.

Now, instead of adding a million keys to the local storage, you add just 1 key to it, give it a name you like, and store the json of the dictionary in its value.

You can ofcourse also write the array you use the same way in the local storage. (1 key, 1 value as json) But the array is in your case (only 1 text + just 1 number) just that little to complicated for what it is.



Thanks for the reply, Unfortunately I've never worked with a dictionary in construct 2 before. I'm not sure how it works.

The only reason I made it this far with the array was due to a video tutorial lol
B
9
S
4
G
2
Posts: 39
Reputation: 1,805

Post » Mon Apr 11, 2016 12:50 pm

B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Mon Apr 11, 2016 6:00 pm



Thank you so much, However When I import this into my Construct 2 and Hit play I can increase the score but the name portion is not working at all It just shows a full line of 0's

I havent changed the code at all I just wanted to see it in action but somethings going screwy on my end
B
9
S
4
G
2
Posts: 39
Reputation: 1,805

Post » Mon Apr 11, 2016 7:12 pm

Okay So I figure I'll upload shots of the entire page so you guys can see what I'm working with.

Event Sheet
http://i.imgur.com/KyOKA7O.png
http://i.imgur.com/2Tmbb47.png
http://i.imgur.com/sXiuuh5.png

(A Note on the second and third screenshot)
To do my letter selection I have 3 sprites one for each letter space.
Then for each letter I have a code that checks which animation frame its on and corresponds that frame to a letter of the alphabet.

So I probably made that WAY harder then it needed to be. so if there's a way to make that whole section of 78 lines of code shorter please. I feel really dumb for only being able to come up with this monstrosity.

Layout
http://i.imgur.com/U6MEbor.png

I apologize as I can not upload the capx Although I know it would make this much easier. I'm working with someone who really doesn't want this on the internet until it's done
B
9
S
4
G
2
Posts: 39
Reputation: 1,805

Post » Mon Apr 11, 2016 10:03 pm

B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Tue Apr 12, 2016 1:49 am

korbaach wrote:Image

example3.capx


Almost Perfect I noticed a bug this created in my game and also found it present in yours.

If two scores on the high score board are the same it edits them both

And also For whatever reason even though (As far as I can tell) I followed the code exactly. My Names erase every time i get to the high score board are replaced with 0's
B
9
S
4
G
2
Posts: 39
Reputation: 1,805

Post » Tue Apr 12, 2016 2:14 am

MrBadAtThis wrote:If two scores on the high score board are the same it edits them both..


fixed.capx

MrBadAtThis wrote:And also For whatever reason even though (As far as I can tell) I followed the code exactly. My Names erase every time i get to the high score board are replaced with 0's


I can not help you without capx...just delete all unnecessary parts of code,replace sprites.. or incorporate
your code in my capx...
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Tue Apr 12, 2016 2:58 am

korbaach wrote:
MrBadAtThis wrote:If two scores on the high score board are the same it edits them both..


fixed.capx

MrBadAtThis wrote:And also For whatever reason even though (As far as I can tell) I followed the code exactly. My Names erase every time i get to the high score board are replaced with 0's


I can not help you without capx...just delete all unnecessary parts of code,replace sprites.. or incorporate
your code in my capx...



Alright Here's the Capx

Thanks again for your help

Capx
B
9
S
4
G
2
Posts: 39
Reputation: 1,805

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests