All-time High Score
W.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
Enjoy..
Current Projects I am working on: Stupid Duck, Zango's Shark Adventure, AoD: Age of Dragons, Rocket Jump: The Pixel Invaders
Facebook: https://facebook.com/reflectivebytegamestudios
Web: reflectivebyte.com
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
So the key can be anything I want, as long as I use the same key to load the attribute?
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
By quitting and restarting do you mean clicking the preview button again in creator? I don't think it saves if you do that.
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
@tatiang I dont have an iOS developer account....will it work on the mac ios simulator? -W.HodgesStudios
@WHodgesStudios you can simulate this by using the REFRESH button on the creator preview. It simulates exiting your app and restarting it
@gingagaming Thanks!
How do I make this "Solved"?