How do I switch between multiple functions with one action

Get help using Construct 2

Post » Sat Dec 12, 2015 12:26 am

Hi guys!
I'm trying, with a simple button pressing, to change the state of an object between 3 sates in this order :
1-stop and shooting
2-moving right and not shooting
1-stop and shooting
3-moving left and not shooting

but cannot find how to make it work :/

Here is a screenshot of what I've got
Image

Any ideas?
Thanks!
B
11
S
4
G
4
Posts: 15
Reputation: 3,185

Post » Sat Dec 12, 2015 12:57 am

Don't try to treat these as three separate events, they are not. Use sub-events and ELSE to break out the conditions:
On key pressed
(sub)->IsMoving
(sub)(sub)->isLeft -> event 3 stuff
(sub)(sub)Else -> event 2 stuff
(sub)Else ->event 1 stuff
ImageImageImage
B
71
S
21
G
233
Posts: 3,696
Reputation: 130,368

Post » Sat Dec 12, 2015 4:17 am

@blackhornet solution is best here.

The way you have it @holi, if the first one fires when the Espace is pressed, and isMoving is 0, your actions set isMoving to 1 so on the next event when we check if isMoving is 1, it actually is now and it can fire. Doing it the way blackhornet suggest will stop this from happening (isolating the conditions).
B
42
S
18
G
8
Posts: 496
Reputation: 8,412

Post » Sat Dec 12, 2015 7:02 am

@blackhornet @humanescape Thank you guys!
B
11
S
4
G
4
Posts: 15
Reputation: 3,185


Return to How do I....?

Who is online

Users browsing this forum: Bootfit, Construct Monkey, Freak Workshop and 23 guests