Load and Save Attribute Question

Is there a way to save a high score so that it loads after the game application has been closed? I used the save and load attribute behaviors as demonstrated in TShirtBooth's video () to have my game save a persistent high score value that starts at zero but then is updated each time a new high score is reached. I then loaded my game adhoc onto my iPhone 4 to test it out. The load and save attribute behaviors work as long as I don't close the app, but when I close the app and reopen it, the high score value resets back to zero. How can I get my game to save the high score after closing?

Comments

  • gamesfuagamesfua Member Posts: 723
    If you're saving and loading properly than most likely the result you want can be achieved. You need to have LOAD triggers set up. For instance, at the very start of your game, ensure that you have a LOAD attribute load for the high score. Perhaps even have a load/save attribute every time you change scenes, or every x amount of time. Whatever you need to ensure a constant update of the load/save. Remember that loading and saving need to be triggered. There needs to be some kind of code that says when to load and save. The more you do that, the more you should be able to have the game consistantly call upon the load or save.
    Hope this helps!
  • gamesfuagamesfua Member Posts: 723
    Give you an example. Lets say I have one scene that displays the high scores. Well I can have code that says IF current score is higher than HIGH score, then replace HIGH SCORE with CURRENT SCORE and save. Thus creating a new saved high score. But if I JUST did that, then the high score on that current page would not update. It would actually still show the previous high score. Why? Because what I needed to do was put one extra line of code in that save coding. I needed to then say, directly after SAVING, now LOAD that HIGH SCORE ATTRIBUTE. Thus triggering the high score to update to the latest save data. Make sense?
  • galaseagalasea Member Posts: 17
    Every time an event occurs that changes the score, I have a rule that checks if the current score is greater than the saved high score. If it is, it will save the current score value into the high score key, so the high score key is being saved quite frequently.

    On my loading screen, I have a hidden actor with the load attribute behavior that loads the high score key, although I don't have any rules or whatnot to govern the load attribute behavior. Do you have any recommendations for improving that?
  • galaseagalasea Member Posts: 17
    Interesting. That example makes what you're saying much clearer. I'll try that and see if that works. Thanks!
  • galaseagalasea Member Posts: 17
    As a follow-up question, what is a good way to make sure that the load attribute behavior on my loading screen is triggered?
  • gamesfuagamesfua Member Posts: 723
    edited December 2012
    Start of the game is a good thing. You could also add a timer that says after .01 seconds load. You can also do it anytime it loads a new scene because a new scene will always trigger the initial triggers in your scene. I have a feeling you have almost everything right, its just not loading the high score after you saved it. Make sure your score DISPLAYS the high score attribute. And make sure theres a load attribute triggered to display it. Use my example below:
    Current score is 20 my high score is 40.
    Suddenly i get 41.
    If current score (41) is higher than high score (40) then change attribute high score (40) to current score (41). Then save high score (41).
    Now load high score (41) so as to update the display in the current scene.
    (This should all be inside the one rule of "if current is higher than high score than xyz...")

    The load was triggered by the save. When it saw that the current score was higher than the old high score, it not only saved it, but ensured to RELOAD the new save file so it could be updated and displayed.
  • BigDaveBigDave Member Posts: 2,239
    Is save and load supposed to work on Adhocs? It doesnt on mine(if i shut down the app properly)
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    hi Bigdave

    yes it does work, but this thread is so old the information contained might be bad. better opening a new thread.

    make sure you're not typing your keys into the expression editor (little e), they should be typed directly into the box.
Sign In or Register to comment.