Boolean, 5 operators then new picture

gurrafgurraf Member Posts: 5
edited June 2014 in Working with GS (Mac)

Hi,
I was hoping someone could help me out, I'm still new at Gamesalad, but trying to make what I guess is a boolean attribute.
My goal is, when I have pressed 5 buttons (in random order) I want a new single button to appear at its own. After each of the 5 is pressed they should not be able to be pressed again.
I would very much appreciate your help!
Thanks in advance!

Comments

  • colandercolander Member Posts: 1,610

    Use a combination of self and game level attributes. To make each individual actor so it can only be clicked once use a self attribute. You can use a boolean or an integer I prefer integers 0 = off/false and 1 = on/true. Create it in the actor and call it switch and set it to 1 (On). Place a change attribute in your rule - self.Switch To 0 this will switch it off when the actor is clicked. Add a condition to your rule - Attribute self.Switch = 1. Now when you click the actor it will only work once.

    Create a game level attribute call it iCount (The i stands for integer so you know what type it is when you are looking at many of them in the expression editor) to count each actor as it is clicked. Use a Change Attribute - iCount To iCount + 1 and place it in the same rule at the top, do this for each of the five actors.

    In the sixth actor use the game level attribute in a rule with the condition Attribute game.iCount = 5 then in the rule move or spawn your actor onto the screen.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Instead of a boolean attribute, use an integer attribute. Each button actor should add one to that attribute (change attribute game.count to game.count+1) when touch is pressed. Have a separate rule that says When attribute game.count≥5 then spawn actor and change attribute self.locked (yes, this should be a boolean) to true. In the initial touch is pressed rule, also have the condition attribute self.locked is false.

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

  • MattButlerStudiosMattButlerStudios Member Posts: 486

    If you are using the same button actor multiple times in your scene as the 5 buttons you can simply create a self attribute inside of the button actor. This attribute will need to be Boolean so that you can turn on and off when the button can be pressed. You could name this something like pressed. Next make a game level attribute that is an index attribute. You could name this buttonCount or something like that. Inside of the button make a rule that states when touch is pressed change attribute (self.pressed) to (true) and change attribute (pressed) to (pressed +1). Now go back to the rule that we created inside of the button actor. Where is says "touch is pressed" add another condition that says when attribute (self.pressed) is (false). Be sure that you your rule says "when ALL conditions are valid and not "when ANY conditions are valid". Now inside of your button actor you can make this rule. "When attribute game.buttonCount = 5 spawn actor". To make is so that they spawn every 5 just keep going up in the amounts. (When game.buttonCount = 10 or 15 or 20 etc..

    Hope this helped. Let me know if you have any questions!

  • gurrafgurraf Member Posts: 5

    Thank you all finally got it to work!

Sign In or Register to comment.