Change images of menus

When I start my game, appear a button "New Game", and then when I play and save all attributes... after close my game and return to play again, how can I use the attribute to change the image of the button "New Game" to "Continue Game"? What attribute use to do this?

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Just change a boolean such as game.Started to true when the game starts. Save that boolean using a Save Attribute behavior and load it when your app starts. Then check the value and if true change the button to Continue Game; otherwise, change the button to New Game.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • pierrenilssonpierrenilsson Member, PRO Posts: 28
    you can do it in lots of ways. For example, when the New Game is pressed, in the next scene or when the button have disappeared, change a table and save it from 0 to 1. if 0 = New Game, if 1=Continue. You can also use attributes, for example an integer but in that case you have to save it and load it in on startup. It is easier to change a cell in a table from 0 to 1. When 0 change self.image to "NewGame.png" otherwise change self.image to "Continue.png"

    There is many ways to accomplish this as I said, this is how i usually do it.
  • doug_smuppetdoug_smuppet Member Posts: 99
    thank you @pierrenilsson , but, how can I use without table? because I don't know alot about tables. I tried put a load attribute on first scene, and when I press the button "new game" I tried say with save attribute to save this... save: self.image as:

    something like that
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Just change a boolean such as game.Started to true when the game starts. Save that boolean using a Save Attribute behavior and load it when your app starts. Then check the value and if true change the button to Continue Game; otherwise, change the button to New Game.
    Have you tried this?

    You wouldn't need to save the image at all... just save a boolean that keeps track of whether or not the game has started. You don't need tables, although tables are great for storing large amounts of values/attributes.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • doug_smuppetdoug_smuppet Member Posts: 99
    @tatiang I'm a little slow, I need create a Game Attribute as boolean called Started, and where I put the Save Attribute behavior ? on new game button?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Yes, you can have When Touch is Pressed rule with Change Attribute and Save Attribute behaviors within the rule. The Load Attribute behavior would go on your first scene in any actor and should not be within a rule (unless you have a reason for one).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • doug_smuppetdoug_smuppet Member Posts: 99
    edited March 2013
    not worked, or rather... I don't know how do this..

    1 - I create a Game Attribute as boolean called Started.

    2 - I create a actor Loadgame (in first scene)
    ......|_ Put Load Attribute behavior and
    ..........|_ From: load_button_continue load: game.Started

    3 - On button "New Game"
    ......|_ Rule (When Touch is Pressed)
    ..........|_ Change Scene (to level 1)
    ..........|_ Change Image (set image to: btn_continue)
    ..........|_ Change Attribute
    ..............I_ set: WHAT PUT HERE to: game.Started
    ..........|_ Save Attribute
    ..............I_ save: game.Started as: load_button_continue
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You're almost there. You don't have to do this, but I have a habit of always naming save/load keys the same as the attribute they are using.

    1 - I create a Game Attribute as boolean called Started and set it to false.

    2 - I create a actor Loadgame (in first scene)
    ......|_ Put Load Attribute behavior and
    ..........|_ From: Started load: game.Started

    3 - On button "New Game"
    ......|_ Rule (When Touch is Pressed)
    ..........|_ Change Attribute game.Started to true
    ..........|_ Save Attribute
    ..............I_ save: game.Started as: Started
    ..........|_ Change Scene (to level 1)
    ..........|_ Change Image (set image to: btn_continue)

    In your button actor, you would do:
    When/If game.Started is true
    ..........|_ Change Image (set image to: btn_continue)
    ..........|_ Otherwise/Else
    ...............|_ Change Image (set image to: btn_start)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • doug_smuppetdoug_smuppet Member Posts: 99
    @tatiang it's worked... but, only when I press the Preview, when I close the Preview and play again, didn't work, It shouldn't work in this part also.
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    the preview doesn't save state when you close it, so many that's the problem? You need to do an adhoc build to really test the implementation.
  • doug_smuppetdoug_smuppet Member Posts: 99
    @jonmulcahy really? little weird.. because in my game I created save/load attributes to Lives of my player. when I close the preview and open again, still there, only reseted when I close the GS program.
Sign In or Register to comment.