How to keep track of home runs

LordTarantorLordTarantor Member, PRO Posts: 890
edited November -1 in Working with GS (Mac)
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.

Comments

  • quantumsheepquantumsheep Member Posts: 8,188
    Every time you make a home run, you'd change an integer attribute (let's call it 'home run') to home run+1

    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 :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • firemaplegamesfiremaplegames Member Posts: 3,211
    Whenever you score a home run, add a Save Attribute behavior, like this:

    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!
  • LordTarantorLordTarantor Member, PRO Posts: 890
    Oh thanks a lot guys I will do that right now
  • LordTarantorLordTarantor Member, PRO Posts: 890
    It works perfect.
    Thanks guys.
  • quantumsheepquantumsheep Member Posts: 8,188
    firemaplegames said:
    EDIT: Dang! QS beat me to it!

    You snooze you lose, buddy! :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

Sign In or Register to comment.