Local high score (SOLVED)

0 favourites
  • 15 posts
From the Asset Store
Create the right kind of drama with Film Scoring Tools sound library!
  • 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)

  • 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.

  • 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 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?

  • 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.

  • This might help.

    Subscribe to Construct videos now
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

    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

  • This might help.

    Subscribe to Construct videos now

    Thanks ill watch that

  • > 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.

    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

    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)

  • There's a plugin named "Local Leaderboard".

    Search the forum and try it. Quite simple and cool.

  • 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

    game.reconone.info/files/settings.jpg

  • sotak, first of all, I would put most of the code in the collision section in a function so you don't have to duplicate the code so many times...

    Also, you have several problems with webstorage. You are saving the text "Score" instead of the value of the Score variable, and you don't need to do that every time the score changes. Webstorage is for saving data when you close the game after you are done playing. Then the next time you open the game you can load the data back in (to keep a local all time high score for example). But you are resetting the webstorage "Highscore" field at the start of the game, in event 2, which would wide out the previous high score (if it was being correctly saved). And, on top of that, there are a couple places (events 3 and 7) where you do not have Highscore in quotes - so Construct2 will use the value of the Highscore global variable of zero, rather than the text key "Highscore".

    Now, for the main problem you asked about at the end of the game, it looks like you are setting the Highscore text object to be visible, but I don't see any place where you give it a value.

    So, the main thing to keep straight in your head is that you have three completely separate things here: 1) the global variable Highscore that keeps track of the highest score achieved by the play while the game is running. 2) the Highscore text object that can be used to show that high score to the player on the screen. And 3) the Webstorage "Highscore" field that can permanently save the high score on the players computer hard drive when they quit the game.

    The main flow should go something like this: Load in Highscore from Webstorage if it exists, otherwise create it and set it to zero. Set score to zero. Play game. You have the right idea in event 7, where you add 1 to Score. (but you can take out the Webstorage line there)

    Then when the game ends you want to check if Score > Highscore, then set Highscore = Score, and save it to webstorage. Then set the text object Highscore to something like "Your score="&Score&", High Score="&Highscore... then button to restart the game...

  • sotak, first of all, I would put most of the code in the collision section in a function so you don't have to duplicate the code so many times...

    Yeah working on that part haha, its very cluttered right now

    [quote:2hjoc6f3]

    You are saving the text "Score" instead of the value of the Score variable, and you don't need to do that every time the score changes.

    But you are resetting the webstorage "Highscore" field at the start of the game, in event 2

    I changed it around a bit more (tried to make it the same score style as the video)

    Do you mean setting the Score to 0 is resetting the Highscore field? or the global number part

    took a screenshot of the video that was linked to show the settings compared to me.

    I even made my names for the txt boxes/keys the same

    Seems like its just one little part that is off but everything looks the same as far as add 1 score (100 for his) and the storage keys.

    http://game.reconone.info/files/new.jpg

    I tried to follow the steps AllanR mentioned along with copying the wording that he used in the video as our structure is for the score is practically the same.

  • I got it to work!

    Not sure how...But was reading some other posts on webstorage just adding in code and changing it around and now it works. Ill upload a fresh copy after i clean it up so anyone looking at this can see what I did (and point out a better way if possible)

    Might be next week sometime, as Im going hunting tomorrow-sunday...but its now saving the highscore!!!!

    Thanks for everyones help, now just gotta figure out what exactly i did that made it work haha so i can use it later in future games

    The last changes I made were following the idea Aphrodite gave herehttps://www.scirra.com/forum/viewtopic.php?f=147&t=95354&hilit=highscore

    I "Think" it was that the game over section (after collision) it was not pulling the saved highscore? maybe...idk Ill try to figure that out and post a full SS / the actual file to help anyone else out who is trying this kind of idea

  • Any chance of that capx?

  • Any chance of that capx?

    Yeah been busy lately, ill upload what i have though it is messy so hah

    Ive added some more comments to hopefully help anyone else trying this kind of local score setup

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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)