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
Hexballs: iOS | Android Number Islands: iOS | Android
B
62
S
23
G
5
Posts: 142
Reputation: 6,952

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
68
S
17
G
3
Posts: 293
Reputation: 7,430

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
269
S
52
G
16
Posts: 2,045
Reputation: 44,069

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
72
S
22
G
290
Posts: 3,885
Reputation: 159,511

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: urkokan and 11 guests

cron