Tags

Add to Favourites

6 Favourites
Construct 3
Construct 3

Buy Construct 3

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

Buy Now Construct 3 users don't see these ads

Tutorial Stats

? 4,644 sessions
? 76 sessions per day
? 10,444 page views
? 172 page views per day

Completion

76%
25%
17%
14%
12%
9%
9%
9%
12%

Report Tutorial

Report this tutorial for spam or for being inappropriate.

Events

First, click the Event sheet 1 tab at the top to switch to the Event Sheet View. A list of events is called an Event sheet, and you can have different event sheets for different parts of your game, or for organisation. Event sheets can also "include" other event sheets, allowing you to reuse events on multiple levels for example, but we won't need that right now.

About events

As the text in the empty sheet indicates, Construct runs everything in the event sheet once per tick. Most screens update their display 60 times per second, so Construct will try to match that for the smoothest display. This means the event sheet is usually run 60 times per second, each time followed by redrawing the screen. That's what a tick is - one unit of "run the events then draw the screen".

Events run top-to-bottom, so events at the top of the event sheet are run first.

Conditions, actions and sub-events

Events consist of conditions, which test if certain criteria are met, e.g. "Is spacebar down?". If all these conditions are met, the event's actions are all run, e.g. "Create a bullet object". After the actions have run, any sub-events are also run - these can then test more conditions, then run more actions, then more sub-events, and so on. Using this system, we can build sophisticated logic for our games and apps. We won't need sub-events in this tutorial, though.

Let's go over that again. In short, an event basically runs like this:

Are all conditions met?

  • Yes: run all the event's actions.
  • No: go to next event (not including any sub-events).

That's a bit of an oversimplification. Construct provides a lot of event features to cover lots of different things you might need to do. However, for now, that's a good way to think about it.

Your first event

We want to make the player always look at the mouse cursor. It will look like this when we're done:

Remember a tick runs every time the screen is drawn, so if we make the player point at the mouse cursor position every tick, they'll always appear to be facing the mouse cursor.

Let's start making this event. Double-click a space in the event sheet. This will prompt us to add a condition for the new event.

Different objects have different conditions and actions depending on what they can do. There's also the System object, which represents Construct's built-in features. Double-click the System object as shown. The dialog will then list all of the System object's conditions:

Double-click the Every tick condition to create an event with it. The dialog will close and the event is created, with no actions.

Now we want to add an action to make the player look at the mouse cursor. Click the Add action link to the right of the event. (Make sure you get the Add action link, not the Add event link underneath it which will add a whole different event again.) The Add Action dialog will appear:

As with adding an event, we have our same list of objects to choose from, but this time for adding an action. Try not to get confused between adding conditions and adding actions! As shown, double-click the Player object, for it is the player we want to look at the mouse cursor. The list of actions available in the Player object appears:

Notice how the player's 8-direction movement behavior has its own actions. We don't need to worry about that for now, though.

Rather than set the player's angle to a number of degrees, it's convenient to use the Set angle towards position action. This will automatically calculate the angle from the player to the given X and Y co-ordinate, then set the object's angle to that. Double-click the Set angle towards position action in the list.

Construct now needs to know the X and Y co-ordinate to point the player at:

The X and Y fields are called the parameters of the action. Conditions can have parameters too, but Every tick doesn't need any.

We want to set the angle towards the mouse position. The Mouse object can provide this. Enter Mouse.X for X, and Mouse.Y for Y. These are called expressions. They're like sums that are calculated. For example, you could also enter Mouse.X + 100 or sin(Mouse.Y) (although those particular examples might not be very useful!). This way you can use any data from any object, or any calculation, to work out parameters in actions and conditions. It's very powerful, and a sort of hidden source of much of Construct's flexibility.

You might be wondering how you'd remember all the possible expressions you could enter. Firstly, you might notice Construct shows some lists as you type. This is called autocomplete and helps show what you can type at each point in an expression. Secondly, there's also the Expressions Dictionary which lists them all. If there's room on your screen, it will appear faded out, so it doesn't distract you until you need it. If it's not there, you can click Find expressions to open it. You can double-click an object in the Expressions Dictionary to see a list of all its expressions. If you double-click an expression, it will also insert it for you, saving you from having to type it out.

Anyway, click Done on the parameters dialog. The action is added! As you saw before, it should look like this:

There's your first event! Try running the game, and the player should now be able to move around as before, but always facing the mouse cursor. This is our first bit of custom logic.

Share this Tutorial

Make games in your browser

You may use this tutorial for any purpose (even commercial) if you properly attribute it. Click here for more information.

Beta Mode: You may find bugs/missing content. Read more & Report Bugs