How to keep track of home runs
LordTarantor
Member, PRO Posts: 890
Hello everybody:
I got a little confused trying to do this save/load attribute.
Let say that I have a baseball game and I want to keep track of how many home runs you make every time you play. Like if you play today and make 3 home runs, tomorrow when you go to play again you will have 3 home runs in your scorecard. I you make 2 home runs, you will have 5 and so on.
I got a little confused trying to do this save/load attribute.
Let say that I have a baseball game and I want to keep track of how many home runs you make every time you play. Like if you play today and make 3 home runs, tomorrow when you go to play again you will have 3 home runs in your scorecard. I you make 2 home runs, you will have 5 and so on.
Comments
Then beneath this 'change attribute' behaviour put in a save behaviour:
Save attribute Home Run - Key: home run stats
Then on your splash or intro scene, have a load behaviour:
Load key: home run stats - Attribute: home run
Then, on your stats screen (where you'll display the total or home runs) just use a display behaviour and press the 'e' key next to the text box. Choose the attribute 'home run'.
That will do it, hope that helps!
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Change Attribute: game.totalHomeRuns To: game.totalHomeRuns + 1
Save Attribute: game.totalHomeRuns to key: TOTALHOMERUNS
(I make the key identical to the attribute I'm saving, just in all caps to avoid confusion)
That will save the attribute.
To load it next time you play, put a load behavior in the game, preferably in the very first Scene. i.e. your logo screen, main menu, etc.
Load Attribute: game.totalHomeRuns from key: TOTALHOMERUNS
----
Loading and Saving only work on the device. Not in the Creator or on the web.
EDIT: Dang! QS beat me to it!
Thanks guys.
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io