Saving Question
Billyd1
Member Posts: 133
Hi, I am creating a guide using GS and I want users to tick things off once they have done them. I have put once the box has been touched spawn actor 'tick' inside the box but how would i make the things they have ticked off save so when they open the app it keeps the ticked boxes saved?
Comments
Instead of spawning the ticks in the checkboxes, I would create a single checkbox actor, but make two graphics for it - ticked and unticked. When you touch it, change the image to the ticked version.
You need to make a global boolean attribute for all of the "things" in your guide. If a player completes one, set the appropriate attribute to true. And then save that Attribute.
So lets say you have 5 checkboxes.
You need five global boolean attributes as well:
checkbox1
checkbox2
checkbox3
checkbox4
checkbox5
They are all initially false (unchecked).
Here is the Rule set for the first checkbox:
Rule
When all conditions are valid:
Touch is pressed
-----Change Image To: "checkbox_ticked.png"
-----Change Attribute: game.checkbox1 To: true
-----Save Attribute game.checkbox1 To Key: CHECKBOX1
Does that make sense?
So you tap the checkbox, switch the graphic, change the attribute and then save the attribute.
That's how you save an attribute.
To load that attribute in when you launch the game, place this Rule in an actor - preferably in your first scene - maybe your logo? or the title scene? Some scene BEFORE the scene with the checkboxes.
Rule
Load Attribute game.checkbox1 From Key: CHECKBOX1
Easy enough, right?
Now, to make it work you need to add a SECOND Rule to the checkbox. This will set the appropriate image:
In checkbox1, after the first Rule set:
Rule
When all conditions are valid:
game.checkbox1 = true
-----Change Image To: "checkbox_ticked.png"
That should do it. You will need to do that for each checkbox in your guide.
Also, keep in mind that saving and loading will NOT work in the preview in GameSalad. It will only work on a device.
Good luck!