How do I do events more efficiently?

0 favourites
  • 7 posts
From the Asset Store
14 amazing sound files of game events like Level Ups, Level Completes, object spawn, object taking etc.
  • 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.

    [attachment=0:abe90mzx][/attachment:abe90mzx]

    But I have that nagging feeling that I could write these events another way. Any advice?

  • 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

  • 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"?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • by pressing X, or right click on your event

  • 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

  • You can use Else at the top level. You can't add Else to a trigger.

  • 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"?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)