I'm making a game where i need to toggle a value, when player presses space bar value changes to 0 and when he again presses the value the value changes to 1, how to implement that please help!!!
Event 1:
Spacebar pressed - add 1 to value
Event 2:
Value higher than 1 - set value to zero
toggle-something
Easiest way would be: variable = 1 - variable With variable being either 0 or 1, it will always toggle (1 - 0 = 1, 1 - 1 = 0)
Easiest way would be:
variable = 1 - variable
With variable being either 0 or 1, it will always toggle (1 - 0 = 1, 1 - 1 = 0)
can you make me a small example file for it?
togglesample.capx
hey thanks for the logic but i figured that my values are only 90 and 270, i've to toggle gravity to 90 or 270 when the space bar is hit. can you help me with code where space bar is hit and gravity toggles with 90 or 270?
Develop games in your browser. Powerful, performant & highly capable.
togglesampleB.capx