How to create various button behaviors - Latching?
Hi,
Not much experience with Gamesalad, but I do have experience programming in a scripting language.
I am having a lot of trouble trying to do something that seems like it should be easy to do: latching buttons. Basically, I want to be able to click the button, and it lights up.... The button remains lit up until you click it again. I can get momentary behavior to work fine.... But if I try to program the button to "latch", I can only click on it once to turn it on... It never responds to mouse movement again.
Here's what I did:
1. I created an actor (the button)
2. I created an attribute for the button called "On Off State"
3. I created a rule with the following conditons: When the mouse button is down, and the value of "On Off State" is 0...... Change Attribute "On Off State" to a value of 1, and display the text "On" on the actor
4. I created another rule with the following conditons: When the mouse button is down, and the value of "On Off State" is 1...... Change Attribute "On Off State" to a value of 0, and display the text "Off" on the actor.
Why can't I get this simple behavior to work? I have tried several variations of this, including making the attribute a game attribute instead of tying it directly to the actor, and it simply doesn't do what I think it should.
Comments
Both of your rule conditions are set to "down" (unless you made a typo). One of them needs to be "up" (released). Also, the rule condition "Mouse is Down" refers to a click/tap anywhere in the scene. You might prefer to use when "Touch is Pressed."
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Yes, It works with the "up," but that is not the behavior I want. I want the button to remain on, until I push it again to turn it off. Think of it like the power button on your computer.
I found a solution:
https://forums.gamesalad.com/discussion/62002/how-do-i-make-a-button-that-turns-on-when-pressed-then-off-when-pressed-again
Glad you found a solution.
Here is another way of doing it.
Sorry, I did misread that.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks Guys!