Local high score (SOLVED)

Get help using Construct 2

Post » Tue Feb 18, 2014 9:52 pm

EDIT 3/4/14.

was able to figure it out with help from those here and a few other posts i read through. Have the "full" capx uploaded to dropbox with some comments on it for anyone else trying this kind, still planning on adding different features to it, powerups, hands etc, but anyone can use what is here for what they want.

https://dl.dropboxusercontent.com/u/146 ... flyer.capx

****************************


Hello, first post here.
found this program about a week ago, wanted to test it for android publishing, but didn't want to fork over the money if it didn't work/was too complex. I was able to find an older version with a "cracked" license and tested it on a sample program and was able to export a sample game to an apk and it ran perfectly on my tablet!

So since it worked, I decided to actually buy it to get updates / actually use it.

My main goal is to make some little games for my nephew for when he gets a bit older.

I found the flappy bird tutorial and followed it to make one and have just modified the files to be a more "zombie like" and will eventually make an Asci txt version of it.

Its working great, have a start screen, but play button which leads straight into the game.

Question is how to save my score. Currently I have it set to If X of pipe is < Bird.X Add 1 to score. And it counts up just fine.

Just not quite sure the best way to add it to a local variable/use the webstorage plugin to save it. Watched a few tutorials on it, but I think my variables are too different then theirs to make it work using their methods.


I can upload a copy or screenshot of what i currently have If needed once I get home.


I believe what I am trying to do is export "score" value (what appears in my scoretext box) to a webstorage and upon my flying object hitting anything ends game and displays the score.


1. display value
2. upon crash, save value to local key?
3. Load score layout
4. display score/local key

Does that sound about right for the process? Don't really care about having more then 1 highscore or sending out to a server for public viewing.


Sorry for the long post just trying to get as much details out for this. you can view it here http://game.reconone.info/ to see what i mean by the score under version 1

It currently asks to save information (I would assume its part of the webstorage)
Last edited by sotak on Tue Mar 04, 2014 9:07 pm, edited 1 time in total.
B
6
Posts: 17
Reputation: 332

Post » Tue Feb 18, 2014 10:01 pm

What problem specifically are you having with high scores? You should easily be able to use the websotrage object to store a delimited string of high scores.

So if you have 10 high scores, load them into an array with size 11, and set the 11th value to the current score, then sort them, and save the first 10 values of the array as your new high scores.

You can load the scores from the webstorage object, and parse them by using float(tokenat(HighScoresString,N,":")) where HighScoresString is your delimited string of high scores, N is the Nth score, and : is your delimiter.Juryiel2014-02-18 22:02:08
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Tue Feb 18, 2014 11:03 pm

Thanks for the reply. Im not getting an error really, I think its just either my syntax is wrong, or not using the correct arguments for it to work so it just stays blank.

Just not too familiar with the proper arguments that are needed
What it currently does for the scoring is
uploaded a screen shot of it here http://game.reconone.info/scoring.jpg

On start of the layout it sets score to 0 to reset.

Not sure which piping would be best to put the value of "score" into a webstorage. If i add a webstorage for local storage, it gives "key" and "value" fields.

Would key be ScoreText.Text? as thats what is keeping track of it as the game goes runs?
B
6
Posts: 17
Reputation: 332

Post » Wed Feb 19, 2014 12:36 am

The key is wherever variable you want to store it to, you can name that whatever you want, as long as you use that same key to load the score. The value is the actual score.
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Wed Feb 19, 2014 1:22 am

B
100
S
32
G
11
Posts: 1,552
Reputation: 21,612

Post » Wed Feb 19, 2014 1:43 am

[QUOTE=Juryiel] The key is wherever variable you want to store it to, you can name that whatever you want, as long as you use that same key to load the score. The value is the actual score.[/QUOTE]

Ok thats good to know. so if i want my key to be highscore, and the value to be what is in ScoreText. Would the proper way of storing it be

sub event under my

if x passes y add 1 to score event.
- webstorage : local key exists >> Action >> webstorage Set local key "highscore" to ScoreText.Text


Score text is what actually appears on the screen as you are playing and counts
B
6
Posts: 17
Reputation: 332

Post » Wed Feb 19, 2014 1:43 am

[QUOTE=ArcadEd] This might help.

http://www.youtube.com/watch?v=06-LgQxceGg[/QUOTE]

Thanks ill watch that
B
6
Posts: 17
Reputation: 332

Post » Wed Feb 19, 2014 1:47 am

[QUOTE=sotak] [QUOTE=Juryiel] The key is wherever variable you want to store it to, you can name that whatever you want, as long as you use that same key to load the score. The value is the actual score.[/QUOTE]

Ok thats good to know. so if i want my key to be highscore, and the value to be what is in ScoreText. Would the proper way of storing it be

sub event under my

if x passes y add 1 to score event.
- webstorage : local key exists >> Action >> webstorage Set local key "highscore" to ScoreText.Text


Score text is what actually appears on the screen as you are playing and counts[/QUOTE]

Yes, but I wouldn't check if the local key exists, you can just write to that key whether it exists or not, it will create it. If you check if the key exists, and the key doesn't exist, then you won't write anything, and therefore won't create it (unless you create it in another action)
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Wed Feb 19, 2014 1:50 am

There's a plugin named "Local Leaderboard".
Search the forum and try it. Quite simple and cool.
B
23
S
8
G
1
Posts: 172
Reputation: 2,780

Post » Wed Feb 19, 2014 3:36 am

the video was very helpful as he has his set similar to mine for the score. Have everything working except the scoring chart at the end it looks like. Can one of you smarter people check my syntax to see if you see anything that stands out here?

Threw up a picture of the start, scoring, and collisions (which end the level and destroy all objects


http://game.reconone.info/files/settings.jpg
B
6
Posts: 17
Reputation: 332

Next

Return to How do I....?

Who is online

Users browsing this forum: mekonbekon, NadeemAbbass and 10 guests