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
13
S
4
G
4
Posts: 29
Reputation: 3,263

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
22
G
288
Posts: 3,859
Reputation: 158,424

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).
If you are looking for solutions and workarounds to the Windows 10 C2 performance issues feel free to reach out to me.

Following rexrainbow's lead - Goodbye.
B
50
S
24
G
14
Posts: 632
Reputation: 12,505

Post » Sat Dec 12, 2015 7:02 am

@blackhornet @humanescape Thank you guys!
B
13
S
4
G
4
Posts: 29
Reputation: 3,263


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, inozz, sebrosen, TheMob000 and 6 guests