Button Changing Boolean
![dshoe](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
Sup GS, I'm trying to make an actor that when pressed will either turn off or turn on a boolean attribute called EraserIsOn depending on whether it is true or false at the time.
Here is my code
If (touch is pressed)
{
If (EraserIsOn == false)
{
EraserIsOn = true;
}
Else (EraserIsOn == true)
{
EraserIsOn = false;
}
}
The product is the attribute changing once, but the second time you press it, it stays the same (actually I noticed it changes but immediately changes back). So what is a way I can change this attribute back and forth with the same actor?
Here is my code
If (touch is pressed)
{
If (EraserIsOn == false)
{
EraserIsOn = true;
}
Else (EraserIsOn == true)
{
EraserIsOn = false;
}
}
The product is the attribute changing once, but the second time you press it, it stays the same (actually I noticed it changes but immediately changes back). So what is a way I can change this attribute back and forth with the same actor?
Comments
when touch is pressed change attibute to (attirubte+1)%2
that will make it so it starts at 0, you press and it turns to 1, and when its one and you press it turns to 0. And it toggles back and forth like that. You can then use 1 and 0 to instead or true and false