Load and save attributes

vegasmike1vegasmike1 Member Posts: 192
edited November -1 in Working with GS (Mac)
I am still perplexed regarding this load and save attribute function. I have a game, I want to save the high score so that the next time a person comes into the game it will be in the nifty text box for high score. However if the player wants to play again, right away, I reset the game from the score screen otherwise when moving to the screen all the variables for the game are still the same, not save, when I reset the game, the high score function gets reset. This is probably not making any sense. But in a normal world I would save this info to disk and then on load of the game or reset I would call that file from the disk. I think that there must be a way as people have made games that save the levels completed so you can CONTINUE which is close enough to a high score. I just dont get it. Anyone have a better explanation on how these two functions work, do they save the score somewhere on the iphone or is just in temp memory as long as the game is live. So help a didiot out here, if you have an answer throw it my way.

Thanks
Mike

Comments

  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    Check out my demo on storing multiple high scores. It makes use of save/load to keep track of scores across sessions in a game.

    http://gamesalad.com/game/play/52365

    Let me know if you have any questions.
  • vegasmike1vegasmike1 Member Posts: 192
    That is perfect and should work if the game is active but what happens if you quit the game and come back another day, so to speak. I downloaded the project into safari but I would like to see the logic in GS, do you have a way so that I can download that also. Looks great. I know that there are people doing some magic to store things away after a LEVEL is completed so that when you come back those levels completed show as unlocked or whatever the standard fare is. Its just that I dont see this save attribute as being saved anywhere other than in the game while its active. (is any of this making sense, I have been farting around with this for 2 days now) sorry to babble. So can I look at your code and if so, how do I get to it.
    Thanks
  • BarkBarkCoBarkBarkCo Member Posts: 1,400
    In GS, go to "Shared Projects" and search for "Leader Board Sort Demo", then click the pencil icon. This demo should work where scores are saved even when the app is exited. Feel free to publish for xcode and test on a device...
  • Sadly I'm not even going to pretend to understand how this works. I'm just going to copy your behaviors exactly and hope it works. :-)
  • CaptainChocoCaptainChoco Member, BASIC Posts: 124
    Hello Daniel.
    You are not the only one who feels that way. haha~
    In GS save/load is not easy...
    I'm trying to make an simple upgrading system for my game but oooh... not easy...
  • It is def not something that is easy to wrap your head around. Maybe someone will make a tutorial about it some day. Hopefully one of the vets like tshirtbooth can help us out but if I figure it out in the future, I'll try and make a tutorial about it.
  • konpavloskonpavlos Member Posts: 17
    a tut would be nice for this
  • JeffreyShimaneJeffreyShimane Member Posts: 372
    Here's how I load/save high scores:

    1) Create a game attribute (HighScore).
    2) When the game ends, create a rule to check if the current score is greater than the high score (this could be changed to greater than or equal to if you prefer). If it is higher, use Save Attribute to save the HighScore attribute with the key of the same name (HighScore), just to make it simpler. If it is not higher, do not save.
    3) In the first scene that loads in your game (for my game, it's the Main Menu), use Load Attribute on one of your objects (I put it in the Main Menu background image) to load the save key (HighScore) into the HighScore attribute. This way, when the app is quit and restarted, the value of HighScore is always reloaded too.

    This method could also be applied to a linear progression of unlocked levels (i.e. you can't skip levels). For example, if you wanted to save the user's current level unlocked, you could use an attribute (Unlock) to load/save the highest level unlocked (the attribute's value gets incremented +1 after each level is finished). If the user quits the app, the next time they start it, their current level unlocked will be restored.

    For a non-linear progression of unlocked levels (or something similar like achievements) that can be unlocked in any order, I'm guessing you'll probably need to use a separate attribute and load/save key to track each level/achievement.

    I hope that helps!
  • HymloeHymloe Member Posts: 1,653
    Hello GAME SALAD, when will I be able to use Save / Load properly in WEB versions of games?

    I want to be able to build a game with Load and Save build in, for testing and playing ont he web, without the iPhone license included.

    When will this be put into the application? Thanks.
  • HymloeHymloe Member Posts: 1,653
    I noticed in the release notes for a recent build...

    GameSalad Creator Beta 0.8.2
    * Load and Save attribute fixed for desktop publishing.

    How does Save and Load work for desktop publishing?

    I want to be able to save my player positionX and positionY on the main map scene as you enter a house for example, change scene to the "house", then when you exit the house scene, you are back at the main map scene, and start at the previous positionX and positionY for the player.

    How can I do this?

    It just seems to reset the scene, as far as I can tell...?

    Would love to know!
  • carlosacj36carlosacj36 Member Posts: 54
    hi, sorry my english, a week ago i were in the same boat,

    solution:
    create2 attributes in game Score Integer or real (i use integer)
    HighScore Integer

    Transfer to Score the value you want using a rule,
    in the same rule,use other rule that say attribute game.Score >game.highscote

    Change attribute game.highscore=score
    Save attribute game.highscore key:highscore (i dont know why but you need to put the same name as the attribute, if not it does not run)

    to show high score

    load attribute
    game.highscore key: highscore
    display text game.highscore

    and every time you close and open tha app, you going to have the value saved, just function using GS viewer in device, no function in GS creator (i think it function, but experts say not)

    any way, if you want to reset that value, just add a change attribute game.highscore=0, togheter with the rule reset scene, or game, but in my opinion, is not logic to reset highscore, but if you want you can.
  • HymloeHymloe Member Posts: 1,653
    OK, I figured out how to do this. :)

    I just need to have my player actor set it's self.positionX to my attribute PlayerPositionX (and the same for Y), all the time, so that each time the scene starts, the player position is initially set from my attribute PlayerPositionX and PlayerPositionY, rather than the X,Y position set by where I've placed my actor in the scene in the editor.

    Is there a way for me to save all my attributes between SESSIONS, without using a device? Such as if I wanted to let players play my game on the Game Salad website, and save their game progress?

    Cheers!
Sign In or Register to comment.