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: 14
Reputation: 3,183

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
19
G
180
Posts: 3,481
Reputation: 103,183

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
38
S
16
G
8
Posts: 469
Reputation: 8,051

Post » Sat Dec 12, 2015 7:02 am

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


Return to How do I....?

Who is online

Users browsing this forum: Jazz813, mekonbekon, SnipG, Yozzik and 13 guests