All-time High Score

W.HodgesStudiosW.HodgesStudios GeorgiaMember Posts: 12

I was wondering how I could get an all-time highscore on my game. It needs to be saved even after I quit the app. I am close to getting it, but I do not understand how the "Save Attribute" works.

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    The video should help but here's the general idea:

    When game.score > game.highscore Change game.highscore to game.score Save attribute game.highscore to key highscore

    In a separate actor (or the same actor if you like) at the top of the rule list outside of any rules...

    Load attribute key highscore attribute game.highscore

    This means that as soon as that scene loads, the high score will be loaded. You can even put this behavior on a different scene (e.g. the first scene in your game)... it's up to you.

    The most important thing is to make sure the two keys are exactly the same. I strongly suggest using the name of the attribute (without the 'game.' prefix) as the key as it keeps things organized.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • W.HodgesStudiosW.HodgesStudios GeorgiaMember Posts: 12

    So the key can be anything I want, as long as I use the same key to load the attribute?

  • W.HodgesStudiosW.HodgesStudios GeorgiaMember Posts: 12

    Okay, I have tested this method. I have a game where the score is updated every time you pass a checkpoint. When the player "dies" I have an actor do this:
    if game.score > game.highscore change attribute game.highscore to game.score .
    Next the actor does this:
    save attribute: game.highscore key: gamehighscore
    My actor that displays the highscore does this:
    load attribute key:gamehighscore attribute:game.highscore.
    When I play within the game, this setup works great. But when I quit the game and restart it, my all-time highscore is erased.

    -W.HodgesStudios

  • asheftasheft Member Posts: 8

    By quitting and restarting do you mean clicking the preview button again in creator? I don't think it saves if you do that.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    You'll need to test it on a mobile device to see the effects of saving and loading attributes.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • W.HodgesStudiosW.HodgesStudios GeorgiaMember Posts: 12
    edited July 2014

    @tatiang I dont have an iOS developer account....will it work on the mac ios simulator? -W.HodgesStudios

  • gingagaminggingagaming FREELANCE GS DEV Member Posts: 1,685

    @WHodgesStudios‌ you can simulate this by using the REFRESH button on the creator preview. It simulates exiting your app and restarting it :D

  • W.HodgesStudiosW.HodgesStudios GeorgiaMember Posts: 12

    @gingagaming Thanks!

  • W.HodgesStudiosW.HodgesStudios GeorgiaMember Posts: 12

    How do I make this "Solved"?

Sign In or Register to comment.