GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Saving and loading high score

Are Skarstein KolbergAre Skarstein Kolberg Posts: 11Member, PRO

I've already posted this in "Working with GS", but I really need some fast feedback on this issue. No spamming intended... So, I have a problem with a game I'm making. It's an endless runner with a timer in one corner, I have "coded" it this way": "Display text-->game.score" (I have integers for score and high score). Further I have put in a timer function, adding 1 to score for each sec (change attribute-->"game.score+1"). When the game ends the scene shifts to a "game over screen" displaying the score. In the score bar I have put in: "display text-->game.score", then a rule: when attribute game.score is higher than game.highscore, change attribute game.highscore to game.score", and save attribute "game.highscore", key: "game.highscore". On the first screen I want to display the highscore, I have put in "display text: game.highscore" and "load attribute: "game.highscore", key: "game highscore". I saw this on youtube, but I can't get it to work. The high score display box in the initial screen just says "0", nothing happens, as if the score isn't being saved..? I want it to load the highest score, and to update when a new high score is achieved. Any ideas?

Comments

  • mhedgesmhedges Raised on VCS Posts: 634Member

    Why not use a table?

    Create a table and call it HighScoreTable. 1 row, 1 column.

    To load the high score from the table, preferably before gameplay starts, do something like:

    Change Attribute game.HighScore to tableCellValue(HighScoreTable,1,1)

    Then at Game Over compare score to high score and proceed accordingly:

    When game.Score > game.HighScore 
    Change Attribute Game.HighScore to game.Score
    

    Update the table:

    Change Table Value HighScoreTable Row 1 Table 1 to game.HighScore

    Then save it:

    Save Table HighScoreTable

  • Are Skarstein KolbergAre Skarstein Kolberg Posts: 11Member, PRO

    Thanks, but still can't get it right. I did make a table, and did as you suggested (I'm not quite sure what you meant). Still nothing.

  • mhedgesmhedges Raised on VCS Posts: 634Member
    edited June 2016
  • mhedgesmhedges Raised on VCS Posts: 634Member

    Look at this demo file. It has a table, actors, attributes and behaviors. Study the relationship among all times carefully.

  • Are Skarstein KolbergAre Skarstein Kolberg Posts: 11Member, PRO

    Thanks, I've checked it. I did copy some of the attributes (not copy as in copy paste), still doesn't work. Do I have to make a separate "event handler", like in the demo, or can I put all behaviours in the counter actor? I've done that anyway.

Sign In or Register to comment.