GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Saving and Loading a game

Hi All,

I want to add a save and load feature on my game. I have looked in the forums and have a general idea how it works, but not sure how to put it all together. Has anyone came across a good tutorial on this subject?

Comments

  • nadir.alkarbinadir.alkarbi Posts: 94Member, PRO

    You can use Save Attribute, Load Attribute behaviours.

  • IceboxIcebox Posts: 1,483Member
    edited October 2015

    @quinn221 You have a save attribute and a load attribute , both behaviors are linked to each other

    Save attribute: You save the Attribute to a key
    Load attibute: You load the key to the attribute

    The key can be named anything but it must match the save and load attribute

    So for example if you want to save the Coins at the end of your level , You want it to save when the hero collides with the finishing point. Remember the key is just a name you put in so you can name it anything you want

    So you will add a rule

    If Hero collides with finishing point
    Save attribute : Game.Coins to AAA

    then in your intial scene you can place an actor with a load attribute behavior
    Load attribute AAA to Game.Coins

    In this example I called the key AAA , but you can name it anything you want , it should match the save attribute though and its case sensitive, so if I put load attribute aaa to game.coins it wont work.

    Another example if you want to save game.score

    Save attribute Game.score to AbAb

    Load attibute AbAb to Game.score

    and so on , hope it makes sense and good luck

  • quinn221quinn221 Posts: 280Member

    @Icebox1910 Yes it makes sense and seems straight forward... But nothing happens for me

    Here is what I have going on. When my Hero collides with flag pole I have have 3 save attribute to

    game.coins (key money)
    game.playerx (key x)
    game.playery (key y)

    Then on my splash screen I have a continue button

    Actor receive touch is pressed
    **
    Load Attribute **

    Key: y Attribute: game.playery

    Load Attribute

    Key: x Attribute: game.playerx

    Load Attribute

    Key: money Attribute: game.coins

    Am I missing a step?

  • IceboxIcebox Posts: 1,483Member

    @quinn221 im not sure to be honest , are you using GS preview ?

  • quinn221quinn221 Posts: 280Member

    Both on my Preview and the GS Viewer...it should only work in the Viewer, correct?

  • IceboxIcebox Posts: 1,483Member

    @quinn221 When I had this problem I deleted the save and load attribute and re did it , it worked , + you have to reset the game to check if it works on GS viewer , dont exit the viewer everything will restart. If you plan to test it on android viewer it wont work , atleast for me , I had to publish the game to check.

  • quinn221quinn221 Posts: 280Member

    OK, tried it still nothing...could it be because I am jumping from one scene to another. Saving my attributes in scene 3 and loading them from scene 1.

  • quinn221quinn221 Posts: 280Member

    I have been trying different methods all weekend and still no luck. Anyone have any tips or ideas what I am doing wrong.

Sign In or Register to comment.