← Construct apps

Construct apps: cards

One card for each thing you'll need in Construct, to look up while you build. Each says what it's for, how to do it, and links to the lesson that teaches it.

Apps that respond

Nothing happens? Check the event sheet

Each layout runs one event sheet. If a screen's events never seem to run, that layout is probably using the wrong sheet, or none.

  1. Click an empty part of the layout.
  2. In Properties, find Event sheet.
  3. Choose the sheet that has this screen's events.
  4. Preview again.

Watch for: This is the first thing to check whenever a screen does nothing at all.

Construct 3
Adding a layout usually offers to add an event sheet too; say yes, then check it's linked.

Construct updates itself, so a menu name may differ slightly. Lesson: A practice tracker

Add an event and its actions

An event is a row: on the left, when something happens (the condition); on the right, what to do then (the actions).

  1. In the event sheet, choose Add event.
  2. Pick the object, then the condition, such as On clicked.
  3. Choose Add action beside it.
  4. Pick the object, then the action, such as Set text.
  5. Add more actions to the same event if needed: they run top to bottom.
Construct 3
Name objects before you start (SaveButton, TotalText) so you can find them in the lists.

Construct updates itself, so a menu name may differ slightly. Lesson: A practice tracker

Remember a value: global variable

A global variable is a named box that holds one value for the whole app, and keeps it when the app changes screen.

  1. Right-click the event sheet and choose Add global variable.
  2. Give it a name, a type (Number or String for text) and a starting value.
  3. Change it with System, Add to or Set value.
  4. Read it by typing its name in an expression.
Construct 3
Global variables sit at the top of the event sheet.

Construct updates itself, so a menu name may differ slightly. Lesson: A practice tracker

Show a value on screen

The screen only changes when an event sets the text. Join words and values with &.

  1. Add the action: your Text object, Set text.
  2. Put words to show in quote marks: "Total: ".
  3. Join a variable with &: "Total: " & Minutes.
  4. Put it in the same event that changes the variable, or in Every tick.

Watch for: A Text Input always holds text: use int(TextInput.Text) to add what was typed.

Construct 3
If the screen shows the word Minutes, it's inside the quote marks by mistake.

Construct updates itself, so a menu name may differ slightly. Lesson: A practice tracker

On and off: sub-event and Else

One trigger, two branches: a sub-event runs only if its condition is true, and an Else runs only if it was false.

  1. Add the trigger on its own, such as Box on clicked.
  2. Select it and press S for a sub-event; give it a condition and actions.
  3. Select the sub-event and press X for an Else; give it actions.
  4. Preview: one click runs one branch.

Watch for: Two separate events with the same trigger both run on one click and undo each other.

Construct 3
Keys: S sub-event, B blank sub-event, X Else. Select the event first.

Construct updates itself, so a menu name may differ slightly. Lesson: A chores checklist

Keep track

Keep the screen up to date: Every tick

Every tick runs about 60 times a second, so it keeps what's on screen in step with the variables, whatever changed them.

  1. Add event: System, Every tick.
  2. Add actions that show values: Set text, Set width.
  3. Change variables in button events, not here.

Watch for: Don't add to a variable in Every tick: it would add about 60 a second.

Construct 3
Every tick is under System.

Construct updates itself, so a menu name may differ slightly. Lesson: A water tracker

Check a value: Compare variable

Compare variable is true while a variable meets a test, such as Glasses = Goal. It has no green arrow, so it's checked every tick.

  1. Add a condition: System, Compare variable.
  2. Choose the variable, the comparison (=, <, ≥ …) and the value.
  3. Add actions; press X to add an Else for when it's false.
  4. To limit a button, put this in a sub-event and move the action inside it.

Watch for: An action on the event above a sub-event isn't controlled by the sub-event's condition.

Construct 3
Compare variable is under System.

Construct updates itself, so a menu name may differ slightly. Lesson: A water tracker

Make a progress bar

A coloured sprite whose width is worked out from a value, over a grey copy of the full bar.

  1. Draw a coloured rectangle sprite at full width (say 400).
  2. Draw a grey one the same size and send it to the back.
  3. Every tick: set the coloured bar's width to value / goal * 400.
Construct 3
Send to back is on the right-click menu of an object on the layout.

Construct updates itself, so a menu name may differ slightly. Lesson: A water tracker

Show or hide something

Start an object hidden, then show it from an event when it's needed.

  1. Select the object and untick Initial visibility in Properties.
  2. In an event, add the action: the object, Set visible, Visible.
  3. To hide it again, Set visible, Invisible.
Construct 3
Hidden objects still show on the layout while you edit; they're hidden in the preview.

Construct updates itself, so a menu name may differ slightly. Lesson: A water tracker

Screens and lists

More than one screen

Each screen is a layout with its own event sheet. Go to layout moves between them.

  1. In the Project panel, right-click Layouts and add one.
  2. Check its Event sheet property.
  3. On a button's On clicked, add System, Go to layout.
  4. Use On start of layout to set a screen's text as it opens.

Watch for: Objects on one layout aren't on the next. Use a global variable to carry a value across.

Construct 3
Preview starts from the layout you have open; open Layout 1 before you preview.

Construct updates itself, so a menu name may differ slightly. Lesson: A values journal

Keep a list: array and List

An array keeps many values in order; a List object shows them on screen.

  1. Insert an Array: Width 0, Height 1, Depth 1, Global ticked.
  2. Add an entry: Array, Push, back, X axis, the value.
  3. On start of layout: List, Clear (its own event).
  4. A separate event: On start of layout + Repeat Array.Width times → List, Add item Array.At(loopindex).

Watch for: loopindex counts from 0. Keep Clear out of the Repeat event, or only the last entry is left.

Construct 3
Repeat is a condition under System; add it with Add another condition.

Construct updates itself, so a menu name may differ slightly. Lesson: A values journal

One object

Make a sprite clickable

A sprite can't be clicked on its own. Add the Mouse object, and any sprite can be a button.

  1. Insert new object: Mouse (and Touch for tablets).
  2. Add event: Mouse, On object clicked.
  3. Choose left button, clicked, and the sprite.
  4. Add actions as for any button.
Construct 3
Mouse and Touch have no picture on the layout; they're listed in the Project panel.

Construct updates itself, so a menu name may differ slightly. Lesson: Creature stats

Each copy, its own values: instance variables

Instance variables belong to an object type, but each copy (instance) keeps its own values.

  1. Select any copy; in Properties find Instance variables and add them.
  2. Select each copy in turn and fill in its own values.
  3. Read one with Object.name, such as Creature.power.

Watch for: Every copy needs its values set separately.

Construct 3
One sprite with several animation frames (speed 0, Initial frame per copy) gives copies different looks.

Construct updates itself, so a menu name may differ slightly. Lesson: Creature stats

Which copy? Picking

A condition picks the copies it's true for. Actions and expressions in that event use only the picked copies.

  1. Use a condition that picks, such as Mouse on object clicked or On collision.
  2. Actions on that object in the same event apply to the picked copy only.
  3. Object.variable reads the picked copy's value.
Construct 3
An event that picks nothing applies an action to every copy.

Construct updates itself, so a menu name may differ slightly. Lesson: Creature stats