How can i do switcher from 1 to 2 and back by 1 button?

Get help using Construct 2

Post » Tue Feb 28, 2017 8:45 pm

How can i do switcher from 1 to 2 and back by 1 button?
i do something like
-if button pressed and variable = 1 then make variable 2
-if button pressed and variable = 2 then make variable 1

but as i can see, these events work one after one, so i always have my variable = 1

of course, i can do it by 2 buttons, but i wanna with one, is it possible? pls help me
B
4
Posts: 19
Reputation: 232

Post » Tue Feb 28, 2017 8:51 pm

The second event needs "Else" added.
ImageImageImage
B
71
S
22
G
247
Posts: 3,753
Reputation: 137,552

Post » Tue Feb 28, 2017 9:00 pm

yea, thanks, i found guide on the forum about else in this situation, but it works properly only in suck case. but i have under one event subevents about whole group of my sprites, where each has to be switched from 1 to 2 anb back. by using "else" i cant realise it, but i also found that i can do it following way:
--if button pressed and variable = 1 then add 1 to variable
-if variable >1 then make it 0
B
4
Posts: 19
Reputation: 232

Post » Wed Mar 01, 2017 12:31 am

Variable=1 and the else should be subevents of on button pressed and it should work.

You can also toggle the variable between 1 and 2 with one event:

On button pressed
--- set variable to 3-variable

Just be sure the variable starts as 1 or two.
B
94
S
33
G
113
Posts: 5,353
Reputation: 73,267


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests