play/stop

the19thbearthe19thbear Member Posts: 102
edited November -1 in Working with GS (Mac)
Hi.
Im having a simple problem here.
I want to have a play/stop button. The button starts out with a value=0 which equals stopped.
Value 1 equals playing.
i have then made a counter to display what value the button has - it gives me a visual 1 or 0 so i can check what is going on.

i have done this:
Made an integer attribute called stop/play - have the default value=0
Made a button with the following rules:
If actor is pressed+stop/play attribute is 0=change attribute=1
then another rule in the button:
If actor is pressed+stop/play attribute value is 1=change attribute=0

that way i should have made a simple on/off switch that goes between 0 and 1. But it doesnt!

When i test the project, and press the button the value 0 in shows me a flickering between the 2 values and then goes to value 1=playing. when i press the button again, the value doesnt change.
whats wrong?
thanks alot!:)

Comments

  • CoIinCoIin Member Posts: 197
    Is your second if statement inside the Otherwise part?
  • FanStudioUKFanStudioUK Member Posts: 459
    make a rule: when pressed change attribute to (game.variable+1)%2 - so every time you will press it it will give you a value of 0 or 1
  • CoIinCoIin Member Posts: 197
    Slightly less taxing math would be to change attribute to 1-game.variable.
  • the19thbearthe19thbear Member Posts: 102
    doesnt work with the -1 / +1 either.. same thing!
    it worked with the +1)%2 !! thanks! what does this actually do?

    thanks again!
Sign In or Register to comment.