How do I do events more efficiently?

Get help using Construct 2

Post » Wed Oct 08, 2014 7:16 am

I'm trying to wrap my head around events.

Here's an example I'm working with. If the user clicks a mouse, I want ONE of two things to happen.

1. Mouse click - If there is NO wall to the player right, I want the player to move 32 pixels right.

2. Mouse click - If there is a wall to the player right, I want the player to move 32 pixels up.

The point of doing this is to have the player climb over blocks, but only blocks one 32x32 block high.

Jump 3 Logic.PNG


But I have that nagging feeling that I could write these events another way. Any advice?
You do not have the required permissions to view the files attached to this post.
Proud Construct 3 subscriber.
B
24
S
6
G
5
Posts: 207
Reputation: 4,818

Post » Wed Oct 08, 2014 9:42 am

On Left button Clicked
(subEvent)
Player
Platform has wall to right
Player>Set Y to Player.Y -32
Else
Player Set X to Player.X +32
B
50
S
17
G
2
Posts: 110
Reputation: 4,484

Post » Wed Oct 08, 2014 10:04 am

twg wrote:On Left button Clicked
(subEvent)
Player
Platform has wall to right
Player>Set Y to Player.Y -32
Else
Player Set X to Player.X +32


That's what I'm missing. How do I insert an "Else"?
Proud Construct 3 subscriber.
B
24
S
6
G
5
Posts: 207
Reputation: 4,818

Post » Wed Oct 08, 2014 10:08 am

by pressing X, or right click on your event
"If you want to move a mountain tomorrow, you should start by lifting stones today."
B
64
S
14
G
2
Posts: 292
Reputation: 6,678

Post » Wed Oct 08, 2014 10:10 am

On Left button Clicked
(subEvent)
Player
Platform has wall to right
Player>Set Y to Player.Y -32
Else
Player Set X to Player.X +32

in SUB EVENTS you can add ELSE statements
B
255
S
39
G
15
Posts: 1,982
Reputation: 41,005

Post » Wed Oct 08, 2014 12:52 pm

You can use Else at the top level. You can't add Else to a trigger.
ImageImageImage
B
71
S
22
G
248
Posts: 3,758
Reputation: 138,067

Post » Wed Oct 08, 2014 5:29 pm

This is really great. Now I can apply all the logic I've been using in C and JavaScript!!!

I looked for this kind of info in the docs but didn't find it. I think my next blog post will cover this.

Thank you for all your help. Who'd a thunk it was "X"?
Proud Construct 3 subscriber.
B
24
S
6
G
5
Posts: 207
Reputation: 4,818


Return to How do I....?

Who is online

Users browsing this forum: YoHoho and 13 guests