How To do toggle.

Looking to build a team or have a job to offer?

Post » Thu Jul 11, 2013 3:29 pm

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!!!
B
4
Posts: 21
Reputation: 626

Post » Thu Jul 11, 2013 3:39 pm

Event 1:

Spacebar pressed - add 1 to value

Event 2:

Value higher than 1 - set value to zero
B
20
S
6
G
2
Posts: 188
Reputation: 3,420

Post » Thu Jul 11, 2013 3:44 pm

toggle-something

[QUOTE=Mipey] Easiest way would be:
variable = 1 - variable

With variable being either 0 or 1, it will always toggle (1 - 0 = 1, 1 - 1 = 0)[/QUOTE]
ImageImageImage
B
71
S
20
G
202
Posts: 3,572
Reputation: 114,428

Post » Thu Jul 11, 2013 4:54 pm

can you make me a small example file for it?
B
4
Posts: 21
Reputation: 626

Post » Thu Jul 11, 2013 5:16 pm

ImageImageImage
B
71
S
20
G
202
Posts: 3,572
Reputation: 114,428

Post » Thu Jul 11, 2013 6:24 pm

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?
B
4
Posts: 21
Reputation: 626

Post » Thu Jul 11, 2013 6:35 pm

ImageImageImage
B
71
S
20
G
202
Posts: 3,572
Reputation: 114,428


Return to Job Offers and Team Requests

Who is online

Users browsing this forum: No registered users and 1 guest