Construct 2 Official Manual Guide
Construct 2 Official Manual Guide
CONSTRUCT 2
MANUAL
View online: [Link]
2/manuals/construct-2
[Link]
Beta updates
Beta releases of Construct 2 are not quite ready for
prime time, but are released sooner and more regularly
than stable releases. If you want to help test these
releases, at the risk of possible bugs or crashes, you
can find beta releases in the releases list or set
Construct 2 to tell you about beta updates in the
Preferences dialog.
Portable installation
Construct 2 can be used as portable software. In other
words, you can install it to a removable drive (like a USB
stick) and use it on any computer. If you want to do this,
set the install folder to a folder on your removable drive.
Updates
If you already have Construct 2 installed and you're
installing an update, the setup will offer to remove the
last installed copy of Construct 2. You should always
Revision 3 Page 8/765
remove the old version unless you have installed
Construct 2 twice (e.g. to the host computer and also to
a portable drive, in which case uninstalling may remove
the portable install).
Uninstalling
Construct 2 can be uninstalled via Add/Remove
programs (Windows XP) or Programs and features
(Windows Vista and newer) in Control Panel.
Site-wide installations
If you are installing Construct 2 to a lot of computers,
remember the installation is portable. This means it has
no dependencies outside its Program Files folder. You
can install it to multiple machines by installing it to one
machine and copying the installation folder (and any
shortcuts you want) to other computers.
HKEY_CURRENT_USER\Software\Scirra\Construct2\License
Path
This must be a string with the full path to the license file,
e.g. C:\Path\To\[Link] . Your network
administrator must ensure this registry key is preserved
when logging out, and then the license should be
remembered permanently.
HKEY_CURRENT_USER\Software\Scirra\Construct2\HideLic
enseLink
Recommended system
requirements
Windows 7 or newer
Revision 3 Page 16/765
2 GB RAM
2 GHz dual-core processor
A nVidia or AMD graphics card with latest drivers.
We recommend you avoid any hardware using Intel
graphics chips due to their poor performance,
stability, and feature set.
Addon management
Revision 3 Page 20/765
When installing .c2addon files, Construct 2 will attempt
to copy the addons to two places: both the install
directory, and the AppData folder for the current user
(%appdata%\Construct2). This means even if you don't
have permission to write files to the install directory you
can still install addons.
Beginner's tutorial
If you're new, you might want to check out the link to the
Beginner's Guide to Construct 2 tutorial. This is a step-
by-step guide to help get you going making your first
game in Construct 2.
Revision 3 Page 23/765
Examples
If you like examining existing projects to see how
Construct 2 works, you can try opening the Space
Blaster or Ghost Shooter demos. These are advanced
examples so don't be put off by the math or complexity
of them. They're mainly to show off what Construct 2
can do in the hands of an experienced user.
Settings
You can change the Show start page on startup and
Close the start page when I click on something settings
in the Preferences dialog.
3: View tabs
You can click and drag a tab in to one of the views to set
up a side-by-side split screen view.
7: Object Bar
This contains a list of objects in your game. You can
drag and drop objects from here to place them in
layouts. The right-click menu has many options to filter
or display the objects differently. See The Object Bar.
8: Status Bar
At the bottom of the editor window is the Status Bar.
This shows:
9: Top-right buttons
Customising
You can customise the interface to suit your tastes. Any
of the bars can be dragged and dropped to different
positions in the editor window. Also, you can auto-hide
bars to save room: click the pin icon on a bar and it will
shrink to a simple tab. Hover the tab to pop open the
bar.
Layouts
Levels, menus, title screens and other pre-arranged
layouts of objects. In other tools Layouts may be
referred to as scenes, rooms, frames or stages. See the
section on Layouts for more information.
Event Sheets
A list of Events defining the game logic. In Construct 2,
Events are the alternative to programming or scripting.
Revision 3 Page 29/765
Layouts have an associated Event Sheet for their logic.
Event sheets can be re-used between different layouts
with event sheet includes. Event sheets are edited in
the Event Sheet View.
Object Types
An Object Type defines a 'class' of object. For example,
TrollEnemy and OgreEnemy could be different object
types. Multiple instances of an object type can be
created. For example there could be three instances of
the TrollEnemy object type, and five instances of the
OgreEnemy object type.
System object
The System object represents built-in functionality in
Construct 2. It is the only object an empty project
contains. It cannot be added again or removed from a
project. There are no instances of the System object: it
is simply always present and provides access to the
Revision 3 Page 30/765
built-in aspects of Construct 2's game engine. Its
conditions, actions and expressions are documented in
the System reference.
Project Files
Revision 3 Page 31/765
Any other external file can be imported to the project.
For more information, see Project Files.
Common units
In Construct 2, sometimes you need to enter values
such as angles, speeds or sizes. For consistency these
always use the same units in Construct 2, except where
noted by descriptions or tips shown in the editor. The
common units are described below.
Zero-based indexing
To be consistent with programming languages, all
features of Construct 2 using a number of an item in a
list (indices) start from 0 instead of 1. This might seem
odd at first and take some getting used to, but in many
cases it is actually much more convenient than 1-based
indexing.
Folder projects
Projects can be saved to a folder. This stores different
parts of the project in different files. For example, each
layout is saved to a separate file in a Layouts subfolder.
Since .capx files are a ZIP of the project folder, they can
also be converted to a folder project by renaming them
to .zip and extracting the folder project contained within.
Similarly a folder project can be converted to a .capx file
by compressing it to a .zip file and changing the file
extension to .capx.
Revision 3 Page 35/765
Collaborating on projects
Construct 2 does not contain any of its own
collaboration features, since there are already good free
professional-grade tools available which can work with
Construct 2 projects. Save your project as a folder, and
then you can use source control software to manage
contributions to the project. Since project data files are
XML-based, they already work with merging and diff
tools. For a tutorial on setting up a source control
system with a Construct 2 project on Windows with
SVN, see How to collaborate on projects with SVN.
Exporting
To export your project, use the File menu, ribbon or
Project Bar to open the Export Project dialog.
Publishing to mobile
Choose the Cordova export option to publish to major
mobile platforms like iOS and Android. Cordova is a
cross-platform library for mobile publishing, so there are
no specific "iOS" or "Android" options in the Export
dialog; Cordova covers them both.
Publishing to desktop
Choose the [Link] export option to publish to desktop
platforms. This covers Windows, Mac and Linux. As
with Cordova there are not specific "Windows", "Mac"
and "Linux" options in the Export dialog; [Link] covers
them all.
Having the wrong MIME type set can result in the file
either returning "404 Not Found" (which can result in
problems like audio not playing or AJAX requests
failing), or cause the server to send a corrupt file (e.g.
sending an audio file as a text file, causing it to fail to
load).
Offline caching
If you find there is a problem with your MIME types after
exporting and then fix them, the problem may not appear
Revision 3 Page 43/765
to be immediately corrected if the browser has cached
the previous server responses for offline support.
More information
For more reading, see the Mozilla Developer Network
(MDN) article on Configuring server MIME types.
HTML5
HTML stands for HyperText Markup Language. HTML
is the standard way web pages have been made since
the beginning of the internet. HTML5 is the fifth major
revision of the HTML standard, and it started to gain
widespread adoption in 2011. It introduces many new
features, but only a small number apply to games.
However, "HTML5" is still the most appropriate way to
describe the technology used for Construct 2's games.
Javascript is the standard programming language used
Revision 3 Page 45/765
to program web pages, and this is also used to power
Construct 2 games.
Javascript
Javascript is the standard programming language for the
web. It allows web pages to become interactive and in
many ways work like traditional applications. It is also an
industry-agreed standard.
Canvas renderers
The HTML5 <canvas> tag supports two different ways
to draw the game to the web page: a simple 2D context,
and the WebGL context, based on OpenGL ES.
WebGL is usually significantly faster than the 2D
context and has more features, including supporting
effects, but is not always supported. Construct 2
Revision 3 Page 47/765
supports both technologies for rendering the game.
WebGL can be enabled or disabled for each game in
Project Properties. Generally it is advisable to have it
enabled, since the game will probably run a lot faster in
WebGL mode, and effects cannot work without it. If
WebGL is not supported by a user's computer or
device, or it is disabled, Construct 2 will fall back to the
2D context instead. In this case the game can continue
to be played, but it might run a bit slower and not look as
good. You can check which renderer is in use in the
game itself with the system expression renderer, which
returns either "canvas2d" or "webgl".
Audio
Construct 2's game engine supports the Web Audio API
for reliable low-latency playback of sound effects. When
not supported the standard HTML5 <audio> tag is used
instead.
Revision 3 Page 48/765
Offline support
Despite the fact HTML5 games run in a web browser,
Construct 2 games use Service Workers to allow them
to run offline as well. This is very useful for iOS web
apps and Chrome Web Store apps, since some users
may be offline when running the game. Also, the offline
support helps save bandwidth on servers which host the
games: the game files will only ever be downloaded
once, and every visit after that the game will be loaded
locally from disk (while checking for an update in the
background). See the tutorial on offline support in
Construct 2 for more information.
Back up regularly!
Neither the hardware nor software in your computer is
perfect. Computers fail and software can crash. Back up
your projects to protect yourself from losing work. It is
essential to also maintain off-site backups. If all your
backups are in the same computer or saved to disks all
in the same building, catastrophic events like fire,
floods, theft or simultaneous hardware failure can cause
you to lose all your work and backups together.
Security
Never, ever enter usernames or passwords in to events.
These will be visible in plain text in the exported
Javascript, and malicious users will very quickly be able
to take control of the account. If you need to connect to
something like a database, write a server-side script that
Revision 3 Page 52/765
talks to the database, then connect to the URL of the
server.
Performance
There are a number of best practices in regards to game
performance (ensuring the game always runs fast).
Perhaps the most important is when developing for
mobile, test on the target mobile device from the start.
Your computer could be 10 or 20 times faster than your
mobile device, and something which runs fast on your
computer may be unplayably slow on the mobile device.
For more information see the section on Performance
Tips.
Memory use
Some designers are tempted to design entire levels from
lots of large image tiles. This method should be avoided
at all costs since it is extremely wasteful with memory,
and is not used by any professional game designers.
The subject is discussed in detail in the blog post
Remember not to waste your memory.
Effects
Remember effects require WebGL to display, which is
not always supported. Be sure to set up appropriate
fallbacks and test your project with WebGL disabled to
ensure it will appear correctly for users whose systems
do not support it.
Working as an individual
If you are working on a project by yourself, it is probably
easiest to use single-file projects (.capx files). If the
project gets large over time, you may notice Construct 2
spends more time saving and loading projects with
Decompressing CAPX... or Compressing CAPX... in
the status bar. At this point it is probably useful to
convert to a folder project which skips these steps and
will make saving and loading faster.
Mobile
Modern desktop computers are very powerful. Generally
the main problem with performance is getting your game
to run well on mobiles and tablets. It's more difficult to
get good performance on these devices because they
often have much weaker hardware: slower CPUs,
slower graphics chips, and less memory - often by a
factor of 10 or more compared to a desktop computer.
No hardware acceleration
This is rarer, but using too many loops like For, For
Each and Repeat can cause the game to slow down.
Nested loops are especially likely to cause this. To test
if this is the problem, try temporarily disabling the
looping events.
Common misconceptions
The following things are often accused of affecting
performance (as in, the framerate at runtime), but
probably have little or no effect:
More advice
For more information and advice on performance, see
Revision 3 Page 62/765
the blog post Optimisation: don't waste your time. There
are also some useful tips about keeping your events
efficient in the blog post Common mis-used events and
gotchas.
Set text to fps & " FPS, " & round(cpuutilisation [*] 100)
& "% CPU (" & renderer & ")"
Images
Usually object images (including sprite animations) are
the most memory-consuming part of a project. For this
reason Construct 2 estimates the memory use from
images and displays it in the status bar. You should
keep an eye on this number while developing your
project, but it should only be regarded as a rough
estimate since export-time optimisations could change it.
Remember this is based only on images, so your project
will need at least that much memory to run. The blog
post Remember not to waste your memory has advice
on how to best design games to minimise memory use,
and common memory-consuming mistakes.
Audio
Usually images take up the most of a project's memory
use. However it's worth noting how audio is loaded in to
memory.
Sounds
Audio in the 'Sounds' folder is fully decompressed in to
memory. This allows sound effects to be played
Revision 3 Page 71/765
instantly without any latency from having to first load or
decompress the audio, ensuring sound effects are
heard at the appropriate time. Like with images, the
compressed size helps reduce the download but does
not reduce memory use: the sound will be
decompressed in to PCM wave buffers.
Music
Contrary to sound effects, music is streamed. Generally
this means the audio engine will have a small playback
buffer of a fixed length, and while the audio is playing it
is loaded, decoded and played in small chunks that
connect together seamlessly. This means the memory
use is low regardless of the length of the track, and it
can even start playing the audio before it has finished
downloading. This is why music is not pre-loaded while
the loading bar is showing - there's no need to wait for it
to finish downloading before starting the game. However
playback cannot always start immediately, since it may
need to wait for the download to finish buffering, or for
the first chunk to load and decode. In terms of memory
use, the main consideration is simply to make sure long
audio tracks (typically in-game music) is categorised as
music and not sound.
Organising projects
The Project Bar can be used to arrange your project in
to subfolders (licensed edition only). Subfolders can be
added by right-clicking a folder and selecting Add
Revision 3 Page 82/765
subfolder. Then, you can drag and drop folders and
items to organise them in to folders.
Deleting objects
Deleting from the Layout View will not remove an object
from the project completely. The only way to fully
remove an entire object type from the project is to delete
it from the Project Bar.
Importing audio
Right-click either the Sound or Music folders and select
Import to open the Import Audio dialog. This allows you
to pick audio files from your computer and import them
to the project. Construct 2 will convert them to the
necessary formats to support all browsers. To play back
audio, make sure you add the Audio object to the
project.
Projects
Layouts
Layers
Object instances
Animations
Browsing objects
By default the Object Bar shows the project objects
Revision 3 Page 88/765
organised by folders. Double-click a folder to show that
folder's contents. Click the green Up arrow to navigate
back to the parent folder.
Display options
The text at the top of the title bar shows the current filter
or folder if any. By default it shows just the objects on
the current layout (e.g. All 'MyLayout' objects). This
means it will not show objects only on different layouts,
nor project objects like Mouse or Keyboard. These
objects can be accessed via the Project Bar, and also
dragged and dropped in to the layout from there.
Alternatively, the filtering options can be set to display
all project objects in the Object Bar (see below).
Up to root
Return to the root (bottom-level) object folder, as if
clicking Object types in the Project Bar.
Filter objects
Set to Current layout objects to only show objects
which are in the current layout (the default), or All
project objects to show all objects in the project (like
the Project Bar).
Revision 3 Page 90/765
View as
Set to Folder structure to display objects organised
by their subfolders (the default), or Simple List to list
all objects regardless of their folder (there are no
subfolders in this view).
Icon style
Change how the icons are displayed in the Object
Bar, including which direction the bar scrolls in if
there are lots of objects. This can be useful if you
dock the Object Bar somewhere else in the editor,
e.g. along the top or bottom.
Icon size
Change the size of the icons. Smaller icons lets you
fit more icons in the window, but larger icons makes it
quicker to identify objects.
If any objects are selected from the Layout View, the list
is filtered down to only those objects and any other
objects overlapping them. The objects selected from the
Layout View are also shown in bold. This makes it
convenient to see the relative Z order of a small area
without having to take in to account the rest of the
layout.
Identifying instances
With lots of the same instances in the list, it can
sometimes be difficult to tell precisely where a particular
instance occurs in the list. To help identify each
instance its UID appears after its name, e.g. Player 41
(meaning a Player instance with UID 41).
View options
You can right-click the Z Order Bar and select Show
active layer only. This further filters down the list to only
display objects on the current active layer (the selected
layer in the Layers Bar), which can be useful when
working with a single layer.
Basic usage
To add a tilemap and start editing it, follow these steps:
If you are dealing with small tiles, you can also right-
click on the tilemap and select a zoom level from the
menu.
Toolbar tools
The Tilemap bar's toolbar has the following options:
Import TMX
Import a .tmx tilemap as used by Tiled. All the tiles in
the object are replaced with tile data from the TMX
file. In Construct 2 a Tilemap object represents a
single layer of tiles, so if the TMX file has multiple
layers you will be asked which layer to import. To
import all layers, create a different tilemap object for
each layer and import them separately. Optionally the
tileset image can also be replaced with the image
from the TMX file.
Revision 3 Page 101/765
Export TMX
Export the current tiles and tileset image in to a .tmx
file as used by Tiled. Note that Construct 2 does not
support all of Tiled's features, so importing then
exporting a TMX may lose some data, such as terrain
definitions. Also since in Construct 2 a Tilemap
object represents a single layer of tiles, the exported
TMX file will also only ever have one layer.
Using tilemaps
If you are designing a tile-based game, you can insert
the Tilemap object and edit tiles in the Layout View. To
find out more, see the manual entry on the Tilemap Bar.
Selection wrapping
Revision 3 Page 108/765
If you select two or more objects, you can wrap the
selection by pressing Enter or right-clicking and
selecting Wrap selection. This allows you to rotate and
stretch the selection as a whole.
Other
Revision 3 Page 109/765
To go to the associated event sheet, press Ctrl + E or
Ctrl + Tab or right-click and select Edit event sheet.
Effects previewing
Effects will be displayed in the layout view if WebGL is
enabled in project properties. If WebGL is disabled, the
layout view will preview as it would at runtime, without
displaying any effects, and using any fallbacks that
have been set up.
Diagram of an event
Creating events
There are a number of ways to add a new event:
Modifying events
Double-click or select and press Enter on condition or
action to edit it.
Clear image
Resets the image to all transparent.
Open
Import an image file from disk in PNG, JPEG, BMP,
TIF, GIF or WMF format. PNG is recommended
since it is lossless, usually compresses well, and
supports alpha transparency.
Save
Export the image to a file on disk in PNG, JPEG,
BMP, TIF or GIF format. PNG is recommended since
it is lossless, usually compresses well, and supports
alpha transparency.
Mirror
Mirror the image horizontally. Hold shift to mirror an
entire animation.
Flip
Flip the image vertically. Hold shift to mirror an entire
animation.
Resize
Adjust the image canvas size, with options to center
align the image, top-left align or stretch to fit.
Zoom buttons
Zoom the image. Alternatively, hold control and scroll
the mouse wheel .
Rectangle select
Select, delete, cut, copy and paste rectangle sections
of the image.
Eraser
Erase sections of the image.
Revision 3 Page 118/765
Pencil
Draw individual pixels or drag 1px-size lines.
Brush
Draw with a colored round brush.
Line
Draw colored lines.
Rectangle
Fill an area with a color.
Fill
Flood fill an area with a color.
Color picker
Pick the primary or second color from the image.
Note holding control and clicking with another tool is
a shortcut for this.
Animations Bar
The animations bar is where multiple animations can be
created for Sprite objects.
Loop
Restart the animation after it finishes.
Repeat count
If not looping, the number of times to repeat the
animation.
Repeat to
The zero based index of the animation frame to
repeat back to if looping or repeating.
Ping-pong
Play the animation alternately forwards and
backwards.
Add frame
Add a new blank animation frame to the end of the
sequence.
Reverse frames
Reverse the order of all the frames in the animation.
Thumbnail size
Adjust the size of the thumbnail icons of each frame
in the bar.
Release number
(e.g. Release 70) Construct 2 does not use the a.b.c
version numbering system. Instead, the version is
simply a number which increments by 1 every time a
new release is published. You should stay up to date
Revision 3 Page 126/765
with the latest version for the most features, best
performance and most reliable stability.
Release architecture
(32-bit or 64-bit) This determines whether you are
using the 32-bit or 64-bit version of Construct 2. If
you're using a 64-bit computer it's recommended to
install the 64-bit version, unless you are using a
portable installation. See Installing Construct 2 for
more information.
Release type
Following the release number and architecture may
optionally be the word checked. Checked builds are
generally for testing and you may occasionally see
check failure dialogs which indicate a possible bug or
problem. You should report any such issues to
Scirra. If the word checked does not appear, it
indicates a release version of Construct 2, which is a
stable build intended for day-to-day usage.
Build timestamp
The date and time the Construct 2 executable was
compiled by Scirra is included. This is occasionally
used by Scirra for diagnostic purposes.
OpenGL information
This section outlines your graphics card and its basic
capabilities. It is important to keep your graphics card
drivers up to date. Many common display glitches
(e.g. objects not appearing or having sections cut off)
Revision 3 Page 127/765
are caused by buggy, out of date drivers. Updating to
the latest version released by your graphics card
vendor often fixes these problems. If you haven't
done before since installing Construct 2, we
recommend you click the Check for driver update link
and try updating your drivers. You may need
administrator permissions and have to reboot your
computer.
License information
This contains the license information if a license has
been purchased. See Using a license for more
information.
Credits page
Lists all the individuals and organisations whose work
has been involved in the creation of Construct 2.
Name
A name identifying this event group, displayed in
large lettering in the event sheet. When enabling or
disabling event groups, the name identifies the group.
Description
(optional) An optional description summarising what
the events in the group do, for your organisational
purposes. This is displayed in smaller lettering
beneath the group name.
Active on start
Determine whether or not the event group is enabled
Revision 3 Page 136/765
when the project begins. If this is unchecked, the
event group is disabled, and none of the events
inside it will run until it is enabled by the Set group
active system action. Events which are inactive on
start are displayed with a faded out font in the title.
PNG recompression
The exported images are in PNG format and can be
recompressed losslessly to reduce their filesize even
more. However, this can slow down the export time
considerably. Use None to skip this - the exported
files will be larger, but the export process will be
quicker. Standard is recommended to ensure the
download size is as small as possible. Brute can be
used if you have an extremely large project or it's
essential to save as much bandwidth as possible, but
the export process can take a very long time in this
mode so it is not recommended. For more information
Revision 3 Page 142/765
on the recompression techniques Construct 2 uses,
see this blog post on Image compression in
Construct 2.
Minify script
The exported Javascript code can be compressed
with Google's Closure Compiler to reduce the
download time. This is called minification. At the
same time the code is obfuscated to make it
extremely difficult to reverse-engineer your project.
For this reason it is highly recommended to always
minify your script on export. Minification requires
Java to be installed. (Note that Java is a different
technology to Javascript.)
Format
The format of the image when exported. In brief, the
formats are as follows:
PNG-32 (default) can store true color images
losslessly (perfectly, without any quality loss) with full
alpha channel transparency. However, it usually also
produces the largest file.
PNG-8 is a 256-color version of PNG. It supports
alpha channel transparency, but within the 256 colors
only. Retro or low-color images should look exactly
the same in PNG-8. Images with more than 256
colors have to be reduced to only 256 colors which
can degrade the image quality. However, Construct 2
uses an advanced dithering algorithm (PNGNQ) to
achieve this color reduction. This means many
images still look almost identical. PNG-8 files are also
often much smaller than PNG-32 files, so using
PNG-8 is a useful way to reduce the download size
of the game.
JPEG is an image format designed for photographic
or highly detailed images. It does not support
transparency at all, so it is not suitable for images
which have any transparent areas or alpha channels
(they will appear as if on a black background).
However, JPEG can achieve the smallest files of all,
depending on the quality setting. This is generally
best for minimising the size of large background
images.
For more information on these formats see the
Revision 3 Page 147/765
Wikipedia articles on PNG and JPEG.
Quality
The quality setting when using the JPEG format.
JPEG quality ranges from 0 (worst quality, smallest
file) to 100 (best quality, largest file). Quality settings
above 85 are often difficult to distinguish from the
original. 75 is recommended as a compromise
between quality and reducing the file size as much as
possible.
MIME types
When publishing a HTML5 game to your own server,
you must set up the correct MIME types. If the server
sends the wrong MIME types, audio may not play in
some browsers.
General
This section contains general settings for the Construct
2 editor.
Update checking
Choose one of: Don't for updates: Construct 2 will
not access the Internet to check for new versions.
This is not recommended, since new versions often
contain significant improvements. Check for beta
updates: Check online for new testing releases from
Scirra. Check for updates: Check online for new
releases from Scirra which have already been tested
by people checking for beta updates.
Reset dialogs
Click this button to reset all dialogs and bars in the
user interface to their default position and size. A
prompt will appear to confirm this, then you must
restart Construct 2 for the change to take effect. This
Revision 3 Page 173/765
is useful if you want to get the default UI back. Also,
if for any reason dialogs appear glitchy or no longer
appear when you try to open them, resetting them
with this option can bring them back.
HTML5 exporter
This section contains settings for Construct 2's HTML5
exporter, as well as the local server used for previewing.
Custom browser
Choose any executable file on disk to be launched
for previewing when the Preview browser is set to
Custom. For example, you may want to install a pre-
release (beta) browser alongside the stable release,
and have the option to also preview in the pre-release
Revision 3 Page 174/765
browser. Alternatively, Construct 2 sometimes cannot
detect the traditional browsers even when they are
installed, so you can manually specify a browser
here.
Autosave
This section contains settings for making autosaves.
Enable autosave
If enabled, Construct 2 will automatically save the
project to a .[Link] file in the same folder on
a regular interval (as determined by Autosave
frequency). In the event of a crash, power failure, or
even just accidentally closing and not saving, the
project can be recovered from the last autosave by
renaming the file with the .[Link] extension
to just .capx and opening it again. This should
minimise the amount of work lost. It is strongly
recommended to keep backups to separate backup
folders using the Backup tab in addition to this, since
Revision 3 Page 176/765
disasters such as fire or disk failure could still result
in lost work if the entire storage media becomes
unusable.
Autosave frequency
How often to make autosaves, if autosaving is
enabled. Note that autosaves cannot be made in
some circumstances, such as when modal dialog
boxes are showing. If an autosave is due in such
circumstances, the autosave will be made as soon as
possible afterwards. The autosave frequency is a
trade-off between possibly being irritating if made
very frequently with a large project (since autosaves
could take a while to complete), versus losing a lot of
work if autosaves are made very infrequently and
there is a crash or power failure. You can also set
autosaves to happen after preview, so once the
browser has loaded the preview for testing then
Construct 2 will make an autosave in the
background, which could be a less intrusive option.
Backup
This section contains settings to help you set up
automatic backup for your work. This is essential to
ensure your work is safe even in the event of
catastrophes like hardware failure, theft, fire or floods.
For more information, see the tutorial Keep your work
safe with Construct 2's backup options.
Misc
This section has miscellaneous settings.
Help links
Construct 2 comes with an offline manual, which you
Revision 3 Page 179/765
can use if your computer has no internet connection
or has temporarily lost connectivity. However, the
online manual's content is likely to be more up to
date, so it is recommended to use the online manual
where possible. Note not all help links are included in
the offline manual, such as some tutorials or other
online resources; these will be opened online
regardless of the setting here. The options in this tab
are as follows: Auto-detect - automatically open the
online manual if Construct 2 detects there is an
internet connection; otherwise open the offline
manual. This is the recommended option since you
will see the most up-to-date content in the online
manual, but automatically fall back to offline content if
your connection is lost. Note this option is only
available on Windows Vista and newer. Always use
offline manual - help links will always launch offline
content, if the content is in the offline manual. Always
use online manual - help links will always launch
online content, regardless of whether an internet
connection is present.
Colors
This section allows you to customise the color theme
used in the Event Sheet View and Layout View.
General
Ctrl + X Cut
Ctrl + C Copy
Ctrl + V Paste
Ctrl + Z Undo
Ctrl + Y Redo
F6 Export project
Layout view
See also: Layout View
X Flip horizontal
Revision 3 Page 188/765
Y Flip vertical
F3 Toggle breakpoint
Left arrow key and Right arrow key Move the selection
sideways between Events, Conditions and Actions
A Add action
C Add condition
G Add group
N Add include
R Replace object
Q Add comment
S Add subevent
Revision 3 Page 190/765
V Add variable
Parameters dialog
The parameters dialog is where you enter expressions,
e.g. the X and Y co-ordinate for Set position.
Escape Cancel
Enter Done
Animations only:
P Preview animation
Revision 3 Page 192/765
THE DEBUGGER
View online: [Link]
2/manuals/construct-2/interface/debugger
Pause
Pause the game so it is no longer progressing. This
is useful to spend a while inspecting some
information at a particular moment. When paused it
turns in to a Resume button; click it again to resume
running.
Step
can only be used when paused. It advances the
game by a single frame. Delta-time (dt) is set as if the
game were running at 60 FPS. This can be useful to
inspect a moment frame-by-frame and watch how an
event like a collision is handled.
Restart
will simply refresh the game, loading it from scratch
again.
Performance summary
Some details about the performance of the game appear
in a light grey. For more advice on performance, see
Performance Tips. The displayed values are, reading
from left to right:
The framerate
(e.g. 60 FPS): how many frames per second the
Revision 3 Page 196/765
game is running at. Most system's displays update at
60 Hz, so the game should run at 60 FPS for optimal
rendering. This value corresponds to the fps system
expression.
The renderer
Revision 3 Page 197/765
(e.g. webgl): whether the game is rendering in
canvas2d or webgl mode. WebGL mode is faster and
supports shader effects. This value corresponds to
the renderer system expression. Some additional
performance details appear in the Performance
section of the System object's inspector view, which
is displaying by default:
Collision checks/sec
(e.g. 1144 (~22 / tick)): how many times in the last
second the engine had to test for a collision between
two objects. Collision checks are invoked by the On
collision or Is overlapping sprite conditions, and
many behaviors perform additional collision checks
automatically. In brackets, the average checks per
tick is also shown. For example if there were 600
collision checks in the last second and the framerate
is 60 FPS, the estimated checks per tick will be 10.
This tells you on average there were about ten
collision checks per frame, although the actual value
will often vary frame-by-frame.
Poly checks/sec
(e.g. 60 (~1 / tick)): most collision checks are very
fast, and the engine can tell trivially that two objects
are not overlapping (by verifying that their bounding
boxes do not overlap). However if two objects'
bounding boxes are overlapping, the engine must do
a more expensive check where the collision polygons
of each object are tested against each other. This
value tells how many checks of this kind were made
Revision 3 Page 198/765
in the last second, as well as with the average per tick
as with the Collision checks/sec value. Usually the
Poly checks/sec value is considerably smaller, but if
it is high, it indicates a possible performance problem.
Profiler breakdown
The profiler shows nested tables identifying how much
CPU time has been spent in each part of the engine,
down to individual event groups. The top-level items are:
Events
A breakdown of how much time was spent running
event logic in the event sheets used by the layout.
This is first broken down in to each event sheet (in
case includes were used), and then further down in
to groups and nested groups of events. This can help
identify the most CPU-intensive events which you
may want to optimise.
Physics simulation
How much time has been spent processing the
Physics behavior. Physics simulation can be very
CPU-intensive. If this value is high, consider using
fewer physics objects.
Draw calls
Revision 3 Page 203/765
How long it took the CPU to issue rendering calls, not
including the time for the GPU to complete them. In
some cases, rendering calls can be quite CPU
intensive, especially when very large numbers of
objects are on-screen. Some browsers also forward
all draw calls to another thread to be processed in
parallel, in which case the Draw calls measurement
will likely be an underestimate.
Engine
The remaining time spent in the Construct 2 engine,
which is the overall estimated CPU with the events,
physics and draw calls times subtracted away. This
includes processing behaviors and other engine
housekeeping.
Breakpoints
When running the debugger, it's possible to set
breakpoints to pause execution of an event sheet on a
specific event, condition or action. For more information,
see the manual entry on breakpoints.
Project properties
The properties for a project can be edited in the
Properties Bar after selecting the name of the project in
the Project Bar, or using the Project Properties shortcut
in Layout Properties.
Name
The name or title of the project.
Version
The version of the project, which conventionally is
four numbers in descending importance (e.g.
[Link]), where the first number is the major version
and the last number is the revision number. This is
also used by several exporters to assign the version
to your published app. It is good practice to increment
this each time you export your project.
Description
A sentence or two giving a short summary of the
project. Several exporters also use this as the
description for your published app.
ID
An ID uniquely identifying your application. This
should be in reverse domain format, such as
[Link]. Some exporters use this
as the ID for your exported app, so try to ensure it will
be unique.
Author
The name of the individual or organisation developing
the project.
Email
Revision 3 Page 207/765
A support or contact email address for the project.
Some exporters use this to fill out the Email field of
the published app.
Website
A link to the author's website or other related web
address. Some exporters use this to fill out the
Website field of the published app.
First layout
Select which layout is the first to appear when the
project is exported. When previewing in the editor
usually a specific layout is previewed, so this setting
has no effect until export.
Pixel rounding
By default Construct 2 objects can be drawn at sub-
pixel positions, e.g. (100.3, 200.8). If the browser is
using linear filtering, this can make fine pixel art
appear blurry. If Pixel rounding is set to On,
Construct 2 objects round their position to a whole
number before drawing, e.g. (100, 201). This
prevents any blurring, and can also prevent "seams"
Revision 3 Page 208/765
appearing on grids of objects. Note this does not
affect their actual X and Y co-ordinates, which can
still be between pixels - it only affects where they are
drawn on the screen.
Preview effects
Whether or not to display effects and blend modes in
the Layout View. If enabled, WebGL must also be
enabled for the effects to appear. If disabled, WebGL
effects are not rendered in the editor, and all objects
are drawn as if they have Normal blend mode.
Window size
The size, in pixels, of the viewport in to the game. It is
only used if Fullscreen in browser is Off. A dashed
line indicating the window size appears in the Layout
View.
Preview browser
Choose which browser is launched when previewing
the project. All major browsers for Windows are
listed. Note Microsoft Edge is only available on
Windows 10+. Use (default) to launch the system
default browser. Use Custom to launch a custom
browser set in Preferences. It is highly recommended
to test in multiple browsers before releasing your
project. It is also possible to choose [Link], which is
essentially a standalone version of the Google
Chrome browser used for desktop publishing; in this
mode, the [Link] plugin also works and can be tested
in preview.
Revision 3 Page 209/765
Fullscreen in browser
Instead of showing the project in a rectangle in a web
page (with this option Off), the display can take up
the entire browser window. There are several
variations; for more information see the tutorial on
supporting multiple screen sizes.
Fullscreen scaling
Only has an effect when a fullscreen mode is in use
(when Fullscreen in browser is not Off). High quality
mode renders at the full resolution of the screen. Low
quality mode first renders at the project Window
Size, and then simply stretches the result to fill the
screen. Low quality mode often improves
performance on low-end systems and is often
suitable for retro-style pixellated games with Point
sampling. However text, downscaled sprites and
WebGL shaders appear with better quality and detail
in high quality mode.
Enable WebGL
Enable the faster and more powerful WebGL
renderer where supported. The canvas 2D renderer
will be used instead if WebGL is not supported. See
the Technology section for more information on
renderers. If WebGL is enabled, effects will also be
previewed in the layout view.
Sampling
Choose between linear (smooth) and point
(pixellated) sampling when resizing images. Linear is
recommended for modern games with hi-res
graphics, and point is better suited to retro games
with blocky pixel art.
Downscaling
Adjusts the tradeoff between rendering quality and
memory use when resizing images to smaller than
their original size (downscaling). The options are:
Revision 3 Page 211/765
Low quality: mipmaps are disabled (reducing memory
use), but downscaled sprites may appear blocky or
pixellated Medium quality: mipmaps are enabled.
Downscaling sprites generally looks better. High
quality: mipmaps are enabled and the spritesheet
after export pads out all images to power-of-two sizes.
This can significantly increase memory use, but can
resolve two minor rendering issues: light fringing that
can sometimes occur along the borders of
downscaled objects, or a quality change in the last
frame of an animation. Do not use this mode unless a
rendering artefact is specifically observed and
selecting this mode can be observed to resolve it: the
increased memory usage can be very significant, and
is not a cost that should be added for no reason. For
more information see Memory usage.
Physics engine
Choose which engine will power the Physics
behavior. It is strongly recommended to use the
Box2D [Link] engine for best performance. The
Box2D web engine is kept only for backwards
compatibility reasons and is no longer being actively
maintained.
Loader style
Change the default loader which is shown while the
game is loading, or while the loader layout is itself still
loading. Note the Free edition can only use the "C2
splash" style. See the tutorial how to make a custom
loading screen for more information.
Revision 3 Page 212/765
Preload sounds
Whether to download and decode sounds before the
game can start. If Yes, then sounds will be
downloaded while the loading bar is showing. If No
then sounds will be downloaded on-demand as the
game runs, which can add a delay on the first time
they are played, but it also means there is less to
download before the game can start. Note this option
does not preload music, which will still be streamed
as the game runs.
Pause on unfocus
If set to Yes, the preview will pause when the browser
window loses focus, e.g. when switching back to work
in Construct 2. This can be useful for certain
workflows such as using continuous preview. If set to
No the preview will continue to run even without
focus, but note switching to another browser tab or
minimising the browser window will still pause (as it
does with published projects).
Clear background
Skip clearing the screen to transparent black at the
start of every frame. This is useful to improve
performance on mobiles (see Performance Tips).
Every tick, the frame is firstly cleared to transparent
black, then secondly the background colour of the
bottom layer is filled in (if not transparent), then finally
objects are drawn. 'Clear background' sets whether to
do the first clear. The layer 'transparent' property sets
whether to do the second clear. If all layouts have
Revision 3 Page 213/765
opaque layers in them, you can safely set 'Clear
background' to 'No' since a layer background will
always clear the screen. If all layouts are completely
obscured by sprites or other objects, you can also set
all layers to transparent to skip both clears every tick.
However, in this case, any areas not covered by
objects will appear glitchy or full of garbage pixel data.
Layout properties
The properties for a layout can be edited in the
Properties Bar after clicking a space in the layout or
selecting the name of the layout in the Project Bar.
Name
The name of this layout.
Event sheet
The associated event sheet that defines how this
layout works. Event sheets can be shared between
layouts using includes if you have a lot of similar
events between layouts.
Active layer
This is the layer new objects are placed on to. It is
also set by selecting a layer in the Layers Bar. The
active layer is displayed in the status bar and is also
shown as a tooltip when inserting a new object. All
newly inserted objects are added to the active layer.
Unbounded scrolling
By default the game window cannot scroll past the
edges of the layout. Set this to Yes to allow unlimited
scrolling in any direction, even past the edges of the
layout.
Margins
The size, in pixels, of the margins. The margins are
the grey areas outside the layout area. This only
affects the Layout View and has no effect when
previewing.
Project properties
A shortcut to view the project's properties.
Global layers
Sometimes many layouts in a project have the same
content on a particular layer, such as for interface or
HUD overlaid on to the game. Changing this content
then becomes a chore since changes must be repeated
on every layout. Global layers are aimed at solving this
problem.
Layer properties
The properties for a layer can be edited in the Properties
Bar after clicking the layer in the Layers Bar. Note this
also changes the active layer - see the active layer
Revision 3 Page 219/765
property in Layout properties for more information.
Name
The name of the layer, which can be used to refer to
the layer in the event system.
Initial visibility
Whether or not the layer is initially visible when
previewing . This is different to the Visible in editor
property which only affects the Layout View.
Background color
The background color for the layer. It is ignored if
Transparent is Yes.
Transparent
Ignore background color and make the layer have a
transparent background.
Opacity
Set the opacity (or semitransparency) of the layer,
from 0 (invisible) to 100 (opaque).
Scale rate
Change the rate at which the layer zooms if scaling is
applied to the layer or layout, a bit like parallax but for
zoom. A scale rate of 0 means the layer will always
stay at 100% scale regardless of the scaling applied.
A scale rate of 100 means it will scale normally.
Parallax
Change the rate at which the layer scrolls in the
horizontal and vertical directions. A parallax rate of
100, 100 means ordinary scrolling, 0, 0 means it will
never scroll (useful for UIs), 50, 50 means scrolling
half as fast, etc. Also useful for multi-layer parallaxing
backgrounds.
Global
See the section above on Global layers. If Yes, it will
override every other layer in the project with the same
name with its own contents and properties.
Overridden layers display this property read-only as
Revision 3 Page 221/765
(yes, overridden). If No its contents and properties
are unique to itself.
Visible in editor
Whether or not the layer is showing in the Layout
View . Note this is different to the Initial visibility
property which only affects previewing. This setting
can also be accessed via the Layers Bar.
Locked
Whether or not the layer is locked in the Layout View.
Objects on locked layers cannot be selected. This
setting can also be accessed via the Layers Bar.
Parallax in editor
If enabled, the parallax properties will also be applied
to the Layout View, allowing you to preview what the
effect will look like.
Plugins
Object types
Instances
Instance variables
Effects
Containers
1 Close Construct 2
2 Copy the plugin's folder to <install
path>\exporters\html5\plugins. You'll see each plugin
has its own folder here, so to add a new plugin create a
new folder and add the plugin's files inside it. For
behaviors, copy to <install
Revision 3 Page 228/765
path>\exporters\html5\behaviors instead.
3 Launch Construct 2 and the plugin or behavior should
be available from the editor.
Plugin
(read only) A reminder of the plugin (kind of object)
this object is based on.
Global
By default, all instances are destroyed when the
layout ends (e.g. when going to the next layout). If
Global is Yes, none of the instances of this object
type will be destroyed when switching layouts.
Layer
The layer the instance is placed on.
Angle
The angle in degrees the instance is oriented at. This
can also be altered with the angle handle in the
Layout View.
Opacity
The instance opacity (or semitransparency), from 0
(transparent) to 100 (opaque).
Position
The X and Y co-ordinates in the layout in pixels. This
is measured to the object's origin (see image points).
This can also be altered by moving the instance in
the Layout View.
Revision 3 Page 233/765
Size
The width and height of the instance in pixels. This
can also be altered by dragging the resize handles in
the Layout View when one instance is selected.
Edit variables
Open the Object Instance Variables dialog.
Edit behaviors
Open the Object Behaviors dialog.
Edit effects
Open the Effects dialog.
Support
Effects require WebGL support in order to display. See
the Technology section on Canvas renderers for more
information about WebGL. In short, not all platforms or
computers support WebGL. Effects cannot display on
these platforms. To ensure your project still appears
correctly when WebGL is not supported, see the section
on Fallbacks.
Blend mode
The Blend mode property works on all platforms, since
it is also supported by the Canvas 2D renderer. It is only
effects that require WebGL support and fallbacks to be
set up.
Fallbacks
If WebGL is not supported, you can specify what to do
using the Fallback property in the Effects category in
the Properties Bar.
Testing
Be sure to test with WebGL both enabled and disabled
in project properties to ensure your fallbacks work
properly and the content always displays reasonably.
You cannot assume all your users will have WebGL
support, even if they use a browser which supports
WebGL, because old hardware or out of date drivers
may result in WebGL being disabled. Proper testing is a
best practice.
Performance
Using too many effects can cause poor performance,
especially on mobile devices. Try to only use effects
when it is important to the appearance of the game.
Family behaviors
Behaviors can also be added to a whole family by right-
clicking the family name in the Project Bar and selecting
Revision 3 Page 248/765
Family behaviors.
Family effects
Effects can also be added to a whole family by right-
clicking the family name in the Project Bar and selecting
Family effects.
Summary
Families are a very powerful feature which are essential
to help keep large projects simple. Instance variables
and behaviors added to families are inherited by every
object in the family, which allows for sophisticated logic
to be easily applied to many object types at once.
Creating a container
To add an object to a container, select one of the
objects you want in the container and click the Create
link in its properties (which appears under the Container
category next to the label No container). A dialog opens
allowing you to choose the object to add to the
container.
Examples
In the following events, assume both TankBase and
TankTurret are in a container.
In this event, when a bullet hits the tank base, only its
associated turret flashes. If the objects were not in a
container, all the turrets in the game would flash, as per
the rules of how events work (since no turret was
referenced in the conditions, the action applies to all of
them). However, since the objects are in a container,
when the TankBase that was hit by a bullet is picked, its
associated turret is also picked. This makes the event
work as intended, and the event treats both objects as if
they were one. This is the crux of containers, and for
some uses like strategy games, there will be a large
number of events taking advantage of this type of
picking to ensure objects work as units and don't
accidentally affect other instances.
Revision 3 Page 253/765
Placing container objects in a
layout
In the Layout View, it's possible to create an instance in
a container by itself. This appears to break rules 1 and 2
under What containers do, since objects in a container
must always create and destroy together. However, the
editor does not enforce this. Instead, any missing
objects are created automatically when the layout starts.
It is a good idea to make sure you create enough
objects anyway so you can edit the object's position,
instance variables, and other properties from the Layout
View.
Scripting
Construct 2 uses the event system exclusively and
does not support any scripting in the editor at all. This is
because the event system is powerful enough to replace
scripting completely. However, if you are a programmer,
you may be interested in extending Construct 2 using
Revision 3 Page 257/765
the Javascript SDK.
Multiple conditions
Adding more conditions to an event progressively filters
the instances to run actions on. For example:
Unreferenced objects
Have a look at the following event:
'Or' blocks
Revision 3 Page 263/765
As mentioned before, all conditions have to be met for
an event to run. This is called a 'Logical AND', because
"condition 1 AND condition 2 AND condition 3..." etc.
must be true. However, you can change an event to run
when any condition is true. This is called a 'Logical OR',
because the event will run if "condition 1 OR condition 2
OR condition 3..." are true.
Summary
Using this event system it's possible to make
Revision 3 Page 265/765
sophisticated logic for games quickly and easily. It is a
very powerful alternative to scripting or programming
languages but much easier for non-technical people to
use.
Inverting conditions
Conditions can be inverted, which flips the thing they
test. For example, the condition Monster is overlapping
Player is true whenever a monster is touching the
player. However, if inverted, it appears with a red invert
icon and means Monster is not overlapping Player.
Breakpoints
It is possible to place a breakpoint on a condition, to
Revision 3 Page 270/765
pause execution when it is reached. For more
information, see breakpoints.
Breakpoints
It's possible to place a breakpoint on an action, to pause
execution when it is reached. For more information, see
breakpoints.
random(360)
Sprite.X
(Player1.X + Player2.X) / 2
[Link]
Numbers
Numbers are simply entered as digits with an optional
Revision 3 Page 273/765
fractional part separated by a dot, e.g. 5 or 1.2.
Text (strings)
Text is also known as strings in programming, and
Construct 2 also sometimes uses this naming
convention. Text in expressions should be surrounded
by double-quotes, e.g. "Hello"
You can use & to build strings out of mixed text and
numbers, e.g. "Your score is: " & score
Operators
You can use the following operators in expressions:
+ (addition)
- (subtraction)
[*] (multiplication)
/ (division)
Revision 3 Page 274/765
% (modulo, remainder after division)
& (build strings, e.g. "Your score is: " & score)
There are also comparison operators =, <>, <, <=, >, >=
for comparing values. They return 1 if the comparison is
true or 0 if false.
Object expressions
Objects have their own expressions to retrieve
information about the object. These are written in the
form Sprite.X (the object name, a dot, then the
expression name). The Expressions panel lists all the
Revision 3 Page 275/765
available expressions in the project, and they are further
documented in the Reference section of the manual.
Behavior expressions
If an object has a behavior with its own expressions,
they are written in the form [Link],
e.g. [Link].
System expressions
The built-in system expressions are listed in the
reference. These include some basic mathematical
functions like sqrt (square root).
Triggers in sub-events
If a trigger is in a sub-event all of its parent event's
conditions must be true at the time the trigger fires,
otherwise the event will not run.
Global variables
Global variables show a globe icon. They are always at
the top level of an event sheet - they are not sub-events
or inside any groups.
Local variables
Local variables are variables placed nested under other
events, or inside a group. They also show with a
different icon to global variables.
Setting a breakpoint
Breakpoints can be toggled on and off for the selected
event block, condition or action by right-clicking on
them, using the Events tab of the ribbon, or pressing the
F3 keyboard shortcut. Breakpoints can also be toggled
while debugging.
Pausing on a breakpoint
Revision 3 Page 287/765
When running the debugger, the game will automatically
pause just before it runs an event, condition or action
with a breakpoint.
Continuing execution
When paused on a breakpoint, the debugger can be
used as normal to inspect or edit values. However the
Pause and Step buttons change in to Continue and
Next.
Limitations
Unfortunately due to the architecture of the Construct 2
engine, breakpoints cannot be placed in the following
locations:
Using breakpoints
Breakpoints can be incredibly useful to learn more about
how your own events work and to help track down
problems. They may take some getting used to in order
to get the most out of them, but once familiar they can
be indispensable.
By default you can add any kind of file to the project, but
you can also set the file filter to only show text-based
files if those are the kinds of files you are looking for.
MIME types
For project files to load correctly after exporting, be sure
to set up the right MIME types on the server.
MIME types
In order for your server to send audio files correctly, it
must be set up with the correct MIME types. If the
Revision 3 Page 293/765
server sends the wrong MIME types, audio may not
play in some browsers.
Custom controls
By default, user-controlled movement behaviors use a
standard set of controls (usually based around the arrow
keys). To change these, set the Default controls
property to No, and set up some events using the
Simulate control action. For an example, see the
Platform 4 (custom controls).capx example in the
Examples folder in Construct 2's install directory. It uses
the following events to change Platform's arrow key and
shift controls to W, A and D:
Revision 3 Page 295/765
The Simulate control action does not have to be used
with keyboard input. For example, it can be used with
touch input to create on-screen touch controls, or with
Gamepad input. Alternatively, you can set up events to
automatically control objects with the Simulate control
action. This allows you to set up computer-controlled
enemies or non-player characters (NPCs), sometimes
loosely referred to as "AI".
8 Direction properties
Max speed
The maximum speed the object can travel at in any
direction, in pixels per second.
Acceleration
The rate the movement accelerates at, in pixels per
second per second. When reversing against the
current movement, acceleration and deceleration
Revision 3 Page 297/765
both contribute to slowing down.
Deceleration
The rate the movement decelerates to rest when not
being moved, in pixels per second per second. When
reversing against the current movement, acceleration
and deceleration both contribute to slowing down.
Directions
Set how many directions the movement can move in.
By default it is 8 Directions, allowing movement on
diagonals. 4 directions prevents movement on
diagonals, and Up & down or Left & right only allows
movement along a single axis.
Set angle
Whether or not the movement should also affect the
objects angle. 360 degree (smooth) will always set
the object's angle to the current angle of motion. 45-
degree intervals will set the object's angle to 8
possible directions. 90-degree intervals will set the
object's angle to 4 possible directions. No means the
behavior will not set the object's angle at all, which is
useful if you want to control this yourself with events
(e.g. to make the object point towards the mouse
cursor).
Default controls
If Yes, movement is controlled by the arrow keys on
the keyboard. Set to No to set up custom controls
using the Simulate control action. For more
Revision 3 Page 298/765
information see Custom controls in the behavior
reference summary.
Initial state
Whether the behavior is initially enabled or disabled.
If disabled, it can be enabled at runtime using the Set
enabled action.
8 Direction conditions
Compare speed
Compare the object's current speed in pixels per
second.
Is moving
True if the object has a non-zero speed (is not
stopped). Invert to test if the object is stopped.
8 Direction actions
Reverse
Invert the direction of motion. Useful as a simple way
to bounce the object off an obstacle.
Set acceleration
Set deceleration
Set max speed
These set the corresponding properties, described
under 8 Direction properties.
Set speed
Set the current speed the object is moving at, in
pixels per second.
Set vector X
Set vector Y
Set the X and Y components of the movement, in
pixels per second.
Simulate control
Simulate one of the movement controls being held
down. Useful when setting Default controls to No.
See Custom controls in the behavior reference
summary for more information.
Stop
A shortcut for setting the speed to zero.
8 Direction expressions
Revision 3 Page 300/765
Acceleration
Deceleration
MaxSpeed
Return the corresponding properties, described under
8 Direction properties.
MovingAngle
Get the current angle of motion (which can be
different to the object's angle), in degrees.
Speed
Get the current object's movement speed, in pixels
per second.
VectorX
VectorY
Get the object's current speed on each axis, in pixels
per second. For example, if the object is moving to
the left at 100 pixels per second, VectorX is -100 and
VectorY is 0.
Relative positioning
The Left edge and Top edge position the object relative
Revision 3 Page 303/765
to the window corners, without changing the object size.
For example, if the Left edge is set to Window right, the
object will always stay the same distance from the right
edge of the window.
Set enabled
Set whether the behavior is enabled or disabled. If
disabled, the behavior will not alter the size or position
of the object.
Bound by
Bullet properties
Speed
The bullet's initial speed, in pixels per second.
Acceleration
The rate of acceleration for the bullet, in pixels per
second per second. Zero will keep a constant speed,
positive values accelerate, and negative values
decelerate until a stop (the object will not go in to
reverse).
Revision 3 Page 307/765
Gravity
The force of gravity, which causes acceleration
downwards, in pixels per second per second. Zero
disables gravity which is useful for top-down games.
Positive values cause a parabolic path as the bullet is
bullet down by gravity.
Set angle
If set to No, the behavior will never change the
object's angle. If set to Yes, the behavior always sets
the object angle to the angle of motion.
Initial state
Whether the behavior is initially enabled or disabled.
If disabled, it can be enabled at runtime using the Set
enabled action.
Bullet conditions
Compare speed
Compare the current speed of the bullet, in pixels per
second.
Bullet actions
Bounce off object
Make the bullet bounce off an object it has just
touched. Since this requires the bullet have only just
touched the object, it is generally only useful in an On
collision event. It will also calculate the angle of
reflection to bounce off realistically depending on the
object's shape and angle. If the bullet is not currently
overlapping the given object, or is stuck deep inside
it, this action will have no effect.
Set acceleration
Set the bullet acceleration in pixels per second per
second.
Set gravity
Set the acceleration caused by gravity, in pixels per
second per second.
Set speed
Set the bullet's current movement speed, in pixels per
second.
Bullet expressions
Acceleration
Get the bullet's current acceleration in pixels per
second per second.
AngleOfMotion
Get the angle the bullet is currently moving at (which
can be different to the object's angle), in degrees.
Note: when the speed is 0, the angle of motion is also
0. Usually this can be worked around by setting the
speed before the angle of motion.
DistanceTravelled
Return the total distance the bullet has moved since
creation, in pixels. This does not take in to account
altering the object position with other actions like Set
Revision 3 Page 310/765
position.
Gravity
Return the currently set gravity property, in pixels per
second per second.
Speed
Get the bullet's current movement speed in pixels per
second.
The Car behavior will bounce off any objects with the
Solid behavior. The effect on the movement depends on
the angle of impact - glancing collisions nudge the car
off its current path, whereas head-on collisions stop it
more or less dead. The amount of speed lost depends
on the Friction property.
Car properties
Max speed
The maximum speed, in pixels per second, the car
can accelerate to.
Deceleration
The rate the car brakes at, in pixels per second per
second.
Steer speed
The rate the car rotates at when steering, in degrees
per second.
Drift recover
The rate the car recovers from drifts, in degrees per
second. In other words, this is the rate the angle of
motion catches up with the object angle. The angle of
motion can never be more than 90 degrees off the
object angle. If the drift recover is greater or equal to
the Steer speed, no drifting ever occurs. The lower
the drift recover, the more the car will drift on corners.
Friction
The amount of speed lost when colliding with a solid,
from 0 (stop dead) to 1 (speed not affected at all). For
example, to slow the speed down by half when
colliding with a solid, set Friction to 0.5.
Set angle
If Yes, the behavior will set the object's angle. If No,
the behavior never changes the object's angle.
Revision 3 Page 313/765
Default controls
If Yes, the car movement is controlled by the arrow
keys on the keyboard. Set to No to set custom
controls. For more information see the behavior
reference summary.
Initial state
Whether the behavior is initially enabled or disabled.
If disabled, it can be enabled at runtime using the Set
enabled action.
Car conditions
Compare speed
Compare the current speed of the car, in pixels per
second.
Is moving
True if the current speed is non-zero. Invert to test if
the car is stopped.
Car actions
Set acceleration
Set deceleration
Set drift recover
Set friction
Set max speed
Set steer speed
Set the corresponding properties. See Car properties
Revision 3 Page 314/765
for more information.
Set enabled
Enable or disable the movement. If disabled, the
movement no longer has any effect on the object.
Set speed
Set the current speed the object is moving at, in
pixels per second.
Simulate control
Simulate one of the movement controls being held
down. Useful when setting Default controls to No.
See Custom controls in the behavior reference
summary for more information.
Stop
A shortcut for setting the speed to zero.
Car expressions
Acceleration
Deceleration
DriftRecover
Friction
Revision 3 Page 315/765
MaxSpeed
SteerSpeed
Return the corresponding properties. See Car
properties for more information.
MovingAngle
Get the current angle of motion (which can be
different to the object's angle), in degrees.
Speed
Get the current object's movement speed, in pixels
per second.
VectorX
VectorY
Get the object's current speed on each axis, in pixels
per second. For example, if the object is moving to
the left at 100 pixels per second, VectorX is -100 and
VectorY is 0.
Initial state
Whether the behavior is initially enabled or disabled.
If disabled, it can be enabled at runtime using the Set
enabled action.
On horizontal step
On vertical step
Triggered for each step along an axis when Stepping
mode is either Horizontal then vertical or Vertical
then horizontal. This can be used to accurately
detect collisions with Is overlapping.
On step
Triggered for each step when Stepping mode is
Linear. This can be used to accurately detect
collisions with Is overlapping.
Rotate clockwise
Rotate counter-clockwise
Set
Adjust the angle of motion. This will calculate new
values for dx and dy reflecting a new angle of motion
with the same overall speed. NOTE: if the overall
speed is 0, then setting the angle of motion has no
effect, because there is no motion. A common
Revision 3 Page 320/765
mistake is to set the angle of motion then the speed,
and find that the angle is not used. Instead simply set
the speed first then the angle of motion and it will
work as expected.
Accelerate
Accelerate either the overall movement, or movement
on a specific axis.
Reverse
Inverts the movement by flipping the signs of dx and
dy.
Set speed
Set the current speed in pixels per second either for
the horizontal or vertical axes, or the overall
movement speed. Setting horizontal or vertical
speeds assigns dx and dy directly. Setting the overall
speed calculates new values for dx and dy such that
they reflect the new overall speed while keeping the
same angle of motion.
Stop
A shortcut for setting both dx and dy to 0, stopping
the movement.
Stop stepping
Only valid in On step, On horizontal step and On
vertical step. Stop the current stepping for this tick.
The object can either go back to its old position
(where it was at the start of the tick) or stay at its
current position (possibly half way between its start
and end positions). Note that in Horizontal then
Revision 3 Page 322/765
vertical or Vertical then horizontal modes, only the
current axis is stopped. The next axis will still
continue stepping, unless you also use Stop
stepping for that axis as well.
MovingAngle
Return the current angle of motion, in degrees,
calculated as the angle of the vector (dx, dy).
Speed
Return the current overall speed in pixels per second,
calculated as the magnitude of the vector (dx, dy).
Initial state
Whether the behavior is initially enabled or disabled.
If disabled, it can be enabled at runtime using the Set
enabled action. #Drag & Drop conditions#
Is dragging
True if the object is currently being dragged by
mouse or touch.
Revision 3 Page 325/765
Is enabled
True if the behavior is currently enabled; false if
disabled by the Set enabled action.
On drag start
Triggered when the object is clicked or touched inside
its collision polygon.
On drop
Triggered when the object is being dragged, and the
mouse button is released or the touch ends.
Drop
Stop dragging the object if it is currently being
dragged. This also triggers On drop.
Fade in time
Time, in seconds, to fade in from invisible. If 0, the
fade in is skipped.
Wait time
Time, in seconds, to wait between fade in and fade
out. If 0, the step is skipped.
Destroy
If set to After fade out, the object is automatically
destroyed after the fade out finishes. If No, the object
is never destroyed by the behavior. Be sure to
destroy objects yourself as necessary, as a build-up
of invisible faded-out objects can cause the game to
slow down.
Fade conditions
On fade-in finished
Revision 3 Page 329/765
On wait finished
On fade-out finished
Triggered when each stage of the fade finishes.
#Fade actions#
Restart fade
Run the entire fade from the beginning again.
Start fade
If Active on start is No, this will begin the fade.
Fade expressions
FadeInTime
FadeOutTime
WaitTime
Return the corresponding properties described under
Fade properties.
Flash conditions
Is flashing
True if the object is currently within a flash duration.
On flash ended
Triggered when the end of the flash duration is
reached, and the object has returned to visible.
Flash actions
Flash
Make the object flash by toggling its visibility on and
off. The 'On' time is the duration in seconds the
object remains visible. The 'Off' time is the duration in
seconds the object remains invisible. The object will
Revision 3 Page 331/765
alternate between these two states for the given
duration in seconds. The object is always set back to
visible after the flash duration finishes.
Stop flashing
If the object is currently flashing, this stops the
flashing and sets the object back to visible. If the
object is not currently flashing this action has no
effect.
Jump-thru properties
Initial state
Set whether the behavior is initially enabled or
disabled. If disabled, the object no longer acts as if it
Revision 3 Page 333/765
is a Jump-thru, and the Platform behavior will always
fall through it.
Jump-thru conditions
Is enabled
True if the behavior is currently enabled. This can be
changed by the Initial state property or the Set
enabled action.
Jump-thru actions
Set enabled
Enable or disable the Jump-thru behavior for this
object.
Line-of-sight properties
Obstacles
Whether to use Solids as blocking line-of-sight, or
Custom, where the objects blocking line-of-sight must
be added using the Add obstacle action.
Range
The maximum distance in pixels that line-of-sight can
reach. If an object is further away than this distance,
the object will never have line-of-sight to it, even if the
intervening space is clear.
Cone of view
The angle of the cone of view in which the object can
have line-of-sight to other objects, relative to the
current angle of the object. For example if this is 180,
Revision 3 Page 335/765
then the object can have line-of-sight to any objects
anywhere in front of it, but never behind it. If 360, the
object can have line-of-sight to objects at any angle.
Line-of-sight actions
Add obstacle
If the Obstacles property is Custom, adds an object
type to count as an obstruction to line-of-sight.
Revision 3 Page 336/765
Clear obstacles
If the Obstacles property is Custom, clears any
object types added as obstacles with the Add
obstacle action.
Line-of-sight expressions
ConeOfView
Range
Retrieve the corresponding behavior properties. For
more information, see Line-of-sight properties.
Some of the gaps have been closed off due to the cell
size being relatively large compared to the size of the
gap. This will make the pathfinding behavior route paths
entirely around the obstacles, and never through them.
We can help fix this by reducing the cell size to 20:
For best efficiency, use the same cell size and border
for all objects using the Pathfinding behavior in a layout.
If different objects use different values, then the
Pathfinding behavior must generate multiple obstacle
grids in memory, and pathfind along them separately.
You should also avoid pathfinding every tick, since this
will cause extremely high CPU usage and also increase
the amount of time it takes for other objects to determine
their paths.
Revision 3 Page 341/765
The grid of obstacles is only determined once on
startup. If objects are moved in the layout, the
pathfinding grid is not updated, and objects will continue
to pathfind as if the objects were in their old positions.
To update the entire obstacle grid use the Regenerate
obstacle map action, but note this is a very CPU-
intense operation and should only be done on one-off
occasions. It is much more efficient to update only small
parts of it (ideally only the area that has changed),
which can be done with the Regenerate region and
Regenerate region around object actions.
Finding paths
Calculating a path can take a long time, especially if the
cell size is small. To prevent this reducing the game's
framerate, the paths are calculated in the background
(using a Web Worker). This means after using the Find
path action, the resulting path is not immediately
available. You must wait for the On path found trigger to
run. Only then can you move the object along the path,
or access the list of nodes from the behavior's
expressions. The game may continue to run for a
fraction of a second in between Find path and On path
found.
Pathfinding properties
Cell size
The cell size, in pixels, of the grid of obstacles. See
above for more details about how this is used.
Revision 3 Page 343/765
Cell border
The amount, in pixels, to expand the cell size by
when testing for obstacles. See above for more
details about how this is used.
Obstacles
If Solids, the behavior will automatically mark cells
touching objects with the Solid behavior as being
obstacles. If Custom, you must define which objects
are obstacles by using the Add obstacle action on
startup.
Max speed
If the Move along path action is used, the maximum
speed in pixels per second the object can move at.
Acceleration
If the Move along path action is used, the
acceleration rate in pixels per second per second.
Deceleration
If the Move along path action is used, the
deceleration rate in pixels per second per second,
used when approaching the final node.
Rotate speed
If the Move along path action is used, the rate at
which the object can rotate in degrees per second.
Note this can affect the speed of the object: if the
rotation speed is low, the object will have to slow
Revision 3 Page 344/765
down on tight corners.
Rotate object
Whether to automatically set the angle of the object
with the behavior to the angle of motion.
Diagonals
Whether paths moving along diagonals are allowed. If
disabled, the result nodes along paths will only ever
change at 90-degree angles (up, right, down and left).
If enabled nodes can move along diagonals as well.
Initial state
Whether the behavior is initially enabled or disabled.
If disabled, it can be enabled at runtime using the Set
enabled action.
Pathfinding conditions
Compare speed
If moving along a path, compare the current speed of
the object in pixels per second.
Is calculating path
True if the object is currently calculating a path in the
Revision 3 Page 345/765
background. This is true between the Find path
action and the On path found or On failed to find
path triggers.
Is cell obstacle
Test if a cell in the obstacle grid is marked as an
obstacle. This is useful for debugging or displaying
the obstacle grid. Note the position is taken in cell co-
ordinates rather than layout co-ordinates.
On arrived
Triggered after Move along path when the object
finally arrives at its destination.
On path found
Triggered after the Find path action once a path has
successfully been found to the destination. The
nodes are now available via the NodeCount,
NodeXAt and NodeYAt expressions, and the Move
along path action can also be used.
Clear cost
Remove all path cost objects added with Add path
cost. You must also use Regenerate obstacle map
for this to take effect.
Clear obstacles
Remove all obstacle objects added with Add
obstacle. You must also use Regenerate obstacle
map for this to take effect.
Find path
Revision 3 Page 347/765
Start calculating a path to a destination in the layout.
This is processed in the background and the results
are not immediately ready after this action; you must
wait until the On path found or On failed to find path
triggers run before the result is known or the path can
be moved along. If this action is used while Is
calculating path is true, the old path is still calculated
and the result triggered, but it then immediately
begins calculating the new path and will also trigger
for that result.
Regenerate region
Regenerate region around object
As with Regenerate obstacle map, but only the
specified area is updated. This is usually
considerably faster than regenerating the entire map.
However as with regenerating the entire obstacle
Revision 3 Page 348/765
map, changes only take effect next tick. Regenerate
region takes a rectangle in layout co-ordinates to
regenerate. Regenerate region around object
similarly regenerates the rectangle in the layout given
by an object's bounding box. Note if multiple
instances have met the event's conditions, this will
regenerate multiple rectangles (one for every picked
object).
Set enabled
Set whether the behavior is enabled or disabled. If
disabled, it will not calculate any paths or move the
object.
Set speed
Set the current speed of the object if it is currently
moving along its path, in pixels per second. This
cannot be negative or greater than the maximum
speed of the behavior.
Stop
If the object is moving along its path, causes it to
stop.
Set acceleration
Revision 3 Page 349/765
Set deceleration
Set diagonals enabled
Set max speed
Set rotate speed
Set the corresponding behavior properties. See the
property definitions above for more information.
Pathfinding expressions
CurrentNode
When moving along a path, the zero-based index of
the node the object is currently moving towards. This
may skip ahead just before the object actually
reaches the next node, in order to help it round
corners.
MovingAngle
The current angle of motion when moving along a
path, in degrees.
NodeCount
The number of nodes in the path that was found.
This is only updated after On path found.
NodeXAt
NodeYAt
Return the position of a node in the path that was
found, in layout co-ordinates, using the zero-based
index of the node. This is only available after On path
found.
Revision 3 Page 350/765
Speed
The current speed in pixels per second when moving
along a path.
Acceleration
CellSize
Deceleration
MaxSpeed
RotateSpeed
Return the current values of the behavior properties.
For more information, see the property definitions
above.
Physics properties
Immovable
If Yes, simulate the object having infinite mass. Its
density is ignored and it will never move.
Collision mask
Use collision mask uses the object's collision
polygon from the Image/Animations editor for physics
Revision 3 Page 354/765
collisions. If it doesn't have a collision polygon it will
use the object's bounding box. Bounding box ignores
the object's collision polygon if any, and for the
purposes of Physics collisions considers the object to
be a rectangle. Circle ignores the object's collision
polygon if any, and for the purposes of Physics
collisions considers the object to be a circle. This
allows objects to smoothly roll along (like for example
barrels). This is especially useful since object's
collision polygons is made out of straight lines, so a
smooth circle cannot be created that way.
Prevent rotation
Lock the object's angle so physics collisions do not
cause it to rotate.
Density
The density of the physics object. Only used if
Immovable is No. The object mass is calculated as
its density multiplied by the area of its collision mask.
The exact density values used are not important and
have no specific units - only the relative density is
significant (i.e. an object with density 6 will be twice
as dense as an object with density 3).
Friction
The friction coefficient of the physics object from 0
(no friction) to 1 (maximum friction). This adjusts how
easily objects move against each other while
touching.
Linear damping
The rate the object slows down over time while
moving, from 0 (no slowdown at all) to 1 (maximum
slowdown).
Angular damping
The rate the object slows down over time while
spinning, from 0 (no slowdown at all) to 1 (maximum
slowdown).
Bullet
Enable enhanced collision detection for fast-moving
objects. This can affect performance, so do not
enable it unless the object moves so fast the physics
engine's standard collision detection is unreliable.
Initial state
Whether the physics simulation is initially enabled or
disabled. If disabled, no physics is processed for the
object, and other physics objects can pass through
the object as if it were empty space.
Physics conditions
Revision 3 Page 356/765
Compare angular velocity
Compare the current angular velocity of the physics
body, in degrees per second. A positive value
indicates clockwise rotation and a negative value
indicates anticlockwise rotation.
Compare mass
Compare the mass of the physics body. This is
determined by multiplying the Density by the area of
the object's collision polygon.
Compare velocity
Compare the current velocity (speed) of the physics
body, in pixels per second. The velocity can be
compared on an individual axis, such as just the X
axis to compare the horizontal motion, or the overall
velocity can be used.
Is enabled
True if the physics behavior is currently enabled.
When disabled the physics body is completely
removed from the physics simulation, so other
physics objects will pass through the object.
Is sleeping
True if the object has been at rest and not moved or
been disturbed for a while, so that the physics engine
can stop processing it. Note objects can still be
moving imperceptibly which can prevent them from
being asleep even when they appear to be stopped.
Revision 3 Page 357/765
Physics actions: Forces
Apply force
Apply force at angle
Apply force towards position
Apply a force on the object, either at an angle,
towards a position, or with custom X and Y axis
forces. Applying a force causes the object to
accelerate in the direction of the force. Forces can be
applied from an image point or the object's origin.
Apply impulse
Apply impulse at angle
Apply impulse towards position
Apply an impulse on the object, either at an angle,
towards a position, or with custom X and Y axis
impulses. Applying an impulse simulates the object
being struck, e.g. hit by a bat. Impulses can be
applied from an image point or the object's origin.
Set velocity
Set the object's current velocity directly, providing a
speed in pixels per second for the X and Y axes.
Enable/disable collisions
By default, all Physics objects collide with each other.
Revision 3 Page 358/765
You can disable collisions between the object and
another Physics object so they pass through each
other. This affects all instances of both object types.
Note: enabling collisions again when objects are
overlapping can cause instability in the simulation.
Physics expressions
AngularVelocity
The current angular velocity (rate of rotation) of the
physics object, in degrees per second.
CenterOfMassX
CenterOfMassY
The position of the center of mass of the physics
object, as calculated by the physics engine. This
depends on the collision mask property, and is not
necessarily in the middle of the object.
VelocityX
VelocityY
The current speed of the physics object, in pixels per
second.
AngularDamping
Density
Elasticity
Friction
LinearDamping
These return the corresponding properties. For more
information, see Physics properties.
Pin conditions
Is pinned
True if the object is currently pinned to another
object.
Pin actions
Pin to object
Pin the object to another object. The relative distance
and angle between the objects at the moment the Pin
action is used is remembered. The Mode parameter
chooses how the object is moved in relation to the
other object:
Position & angle (default): keep the object at its
relative distance and angle to the pinned object. The
Revision 3 Page 363/765
object will appear attached and stay in place as the
other object moves and rotates. Position only: as
before, but the object angle is not changed; it only
maintains its relative position. Angle only: the object
is only rotated relative to the other object, and does
not have its position changed. Rope style: the object
is not rotated, but is kept at a maximum distance from
the other object. Bar style: the object is not rotated,
but is kept at a fixed distance from the other object.
For more examples, see the Pin rope [Link] and
Pin chain [Link] examples in the Examples
folder in Construct 2's install directory.
Unpin
Unpin the object, so it is no longer being positioned
by the Pin behavior.
Pin expressions
PinnedUID
Get the UID of the object currently pinned to, or -1 if
not pinned. For more information on UIDs, see
common features.
Platform properties
Max speed
The maximum floor speed in pixels per second.
Acceleration
The horizontal movement acceleration in pixels per
second per second.
Deceleration
The horizontal movement deceleration in pixels per
second per second. When moving in the opposite
direction to the direction of motion, acceleration and
deceleration combine.
Jump strength
The initial vertical speed of a jump in pixels per
second when the jump key is pressed.
Gravity
The acceleration caused by gravity, in pixels per
second per second.
Jump sustain
Maximum time in milliseconds that the jump strength
is sustained at while the jump control is being held
before the effect of gravity takes over. This allows for
variable height jumps depending on whether the jump
control is tapped or held. For example if set to 200,
then the jump velocity is sustained for up to the first
200ms of holding the jump control.
Default controls
If Yes , movement is controlled by the left and right
arrow keys and the up arrow key to jump. Set to No
to set up custom controls using the Simulate control
action. For more information see Custom controls in
the behavior reference summary.
Initial state
Whether the behavior is initially enabled or disabled.
If disabled, it can be enabled at runtime using the Set
enabled action.
Platform conditions
Compare speed
Compare the current speed of the object in pixels per
second.
Revision 3 Page 368/765
Is by wall
Test if a solid blocking horizontal movement is
immediately to the object's left or right. Jump-thrus do
not count as walls.
Is double-jump enabled
True if double jumps are currently enabled. This is
set by the Double jump property or Set double-jump
action.
Is falling
True if the object is in free-fall.
Is jumping
True if the object is moving upwards.
Is moving
True if the object's speed is non-zero.
Is on floor
True if the object is currently standing on a solid or
jump-thru.
On fall
On jump
On landed
On moved
On stopped
These are animation triggers, which trigger when the
platform movement is moving in to each state. If your
Revision 3 Page 369/765
object has animations for any of these states, you
should set the appropriate animation in each trigger.
This helps save you implementing the logic to detect
state transitions yourself.
Platform actions
Fall through
If the player is currently standing on a jump-thru
platform, this action will make them fall through it.
This is useful for adding an additional control, e.g.
down arrow, to jump down from jump-thru platforms.
Set acceleration
Set deceleration
Set double-jump
Set gravity
Set jump strength
Set jump sustain
Set max fall speed
Set max speed
Set the corresponding properties. For more
information, see Platform properties.
Set enabled
Enable or disable the Platform movement. When
Revision 3 Page 370/765
disabled, the behavior has no effect on the object at
all.
Set vector X
Set vector Y
Manually set the horizontal and vertical components
of motion, in pixels per second. For example, setting
the vector Y to -1000 would cause a jump with
strength 1000, which could be useful for
implementing springs.
Simulate control
Simulate one of the movement controls being held
down. Useful when setting Default controls to No.
See Custom controls in the behavior reference
summary for more information.
Platform expressions
Acceleration
Deceleration
Gravity
JumpStrength
JumpSustain
MaxFallSpeed
Revision 3 Page 371/765
MaxSpeed
Return the corresponding properties. For more
information, see Platform properties.
GravityAngle
Get the current angle of gravity, in degrees.
MovingAngle
Return the current angle of motion in degrees, which
can be different to the object's angle.
Speed
Return the current overall speed in pixels per second.
VectorX
VectorY
Return the current X and Y components of motion, in
pixels per second.
Rotate properties
Speed
The rate of rotation, in degrees per second. Use a
positive value for clockwise rotation and negative for
anticlockwise rotation.
Acceleration
The rate the rotation speed changes, in degrees per
second per second. Use a positive value to
accelerate clockwise and a negative to accelerate
anticlockwise.
Rotate conditions
The Rotate behavior has no conditions.
Rotate actions
Set acceleration
Set speed
Revision 3 Page 373/765
Set the corresponding properties. See Rotate
properties.
Rotate expressions
Acceleration
Return the corresponding Acceleration property.
Speed
Return the current rotating speed, in degrees per
second. A positive value indicates clockwise rotation
and a negative value indicates anticlockwise rotation.
Scroll To actions
Set enabled
Enable or disable the behavior. When disabled, the
scrolling will not be affected.
Revision 3 Page 375/765
Shake
Shake the screen for a duration of time, by randomly
offsetting the scroll position every tick. The
Magnitude is the maximum distance in pixels from
the scrolled position the view will be offset. The
Duration is how long the shake will last in seconds. In
Reducing magnitude mode, the Magnitude will
gradually reduce to zero by the end of the shake
duration. In Constant magnitude mode, the
Magnitude will stay the same throughout the full
duration of the shake, ending abruptly.
Height
Revision 3 Page 377/765
The simulated height of the object, which adjusts the
length of shadow it casts. If the Shadow light height
is less than or equal to the object height, it casts an
"infinite" shadow which goes all the way offscreen; if
it is higher, it uses the relative heights to calculate
how long a shadow to cast. For example two objects
with different heights will cast different length
shadows.
Tag
A tag for this shadow casting object. A Shadow light
object also has a tag, and can be set to only cast
shadows from shadow casters with the same or
different tags to itself. This can be used to have
different Shadow lights casting shadows off different
sets of objects, such as to have shadows working at
different levels of Z order.
Is enabled
True if the behavior is currently enabled so it can cast
shadows.
Set height
Set the height property of the behavior. For more
information see Shadow caster properties.
Set tag
Change the tag of the behavior. For more information
see Shadow caster properties.
Tag
Return the currently set tag for the behavior.
Sine properties
Active on start
If No, the behavior will have no effect until the Set
active action is used.
Movement
The Sine behavior has eight different modes:
Horizontal moves the object left and right on the X
axis
Vertical moves the object up and down on the Y axis
Size makes the object grow and shrink
Width stretches the object wider and narrower
Revision 3 Page 380/765
Height stretches the object taller and shorter
Angle rotates the object clockwise and anticlockwise
Opacity oscillates the object opacity. Note object
opacities can never go less than 0 or greater than
100.
Value only does not modify the object. It simply
stores the oscillating value which can be accessed by
the
Value expression. This can be useful to create
custom effects or modify any other object or behavior
property based on the sine behavior.
Forwards/backwards moves the object in a straight
line back and forth along the angle the object is
facing at, like an angled Horizontal mode.
Wave
The wave function used to calculate the movement.
For a visualisation see this Wikipedia diagram. Sine -
the default smooth oscillating motion based on a sine
wave. Triangle - a linear back-and-forth motion.
Sawtooth - linear motion with a jump back to start.
Reverse sawtooth - reverse linear motion with a jump
back to start. Square - alternating between the two
maximum values.
Period
The duration, in seconds, of one complete back-and-
forth cycle.
Period random
A random number of seconds added to the period for
Revision 3 Page 381/765
each instance. This can help vary the appearance
when a lot of instances are using the Sine behavior.
Period offset
The initial time in seconds through the cycle. For
example, if the period is 2 seconds and the period
offset is 1 second, the sine behavior starts half way
through a cycle.
Magnitude
The maximum change in the object's position, size or
angle. This is in pixels for position or size modes, or
degrees for the angle mode.
Magnitude random
A random value to add to the magnitude for each
instance. This can help vary the appearance when a
lot of instances are using the Sine behavior.
Sine conditions
Compare magnitude
Compare the current magnitude of the movement.
Compare movement
Revision 3 Page 382/765
Compare the current movement property of the
behavior.
Compare period
Compare the current period of the movement, in
seconds.
Compare wave
Compare the current wave property of the behavior.
Is active
True if the behavior is active.
Sine actions
Set active
Enable or disable the behavior. When disabled, the
behavior does not affect the object at all.
Set magnitude
Set the current magnitude of the cycle. This is in
pixels when modifying the size or position, and
degrees when modifying the angle.
Revision 3 Page 383/765
Set movement
Change the movement type of the behavior, e.g. from
Horizontal to Size.
Set period
Set the duration of a single complete back-and-forth
cycle, in seconds.
Set wave
Change the wave property of the behavior, choosing
a different wave function to be used to calculate the
movement.
Sine expressions
CyclePosition
Return a value from 0 to 1 representing the progress
through the current cycle. For example, exactly half
way through a cycle this returns 0.5.
Period
Return the current period of a single complete back-
and-forth cycle in seconds.
Value
Return the current oscillating value. This will alternate
as a positive and negative value centered on zero.
This is useful to create custom effects when in Value
only mode.
Solid properties
Initial state
Revision 3 Page 387/765
Set whether the behavior is initially enabled or
disabled. If disabled, the object no longer acts as if it
is solid, and objects will be able to pass through it.
Solid conditions
Is enabled
True if the behavior is currently enabled. This can be
changed by the Initial state property or the Set
enabled action.
Solid actions
Set enabled
Enable or disable Solid for this object. Be careful not
to trap objects by enabling the solid when an object is
overlapping it; see Avoid crushing/trapping objects
with Solids.
Tags
A single Timer behavior can keep track of multiple
timers. To distinguish between then, a tag is used. A tag
is simply a string, which can be anything. For example,
starting a timer with tag "attack" will trigger On timer
"attack", but not On timer "defend".
Timer conditions
On timer
Triggers either regularly, or once off, after a timer that
Revision 3 Page 389/765
was started with the same tag has reached its
duration. NOTE: this trigger can fire with multiple
instances picked, if their timers all reach their time in
the same tick. This can sometimes work
unexpectedly if the actions expect there to be just
one instance picked. The workaround is to add a For
each condition after this trigger to ensure the actions
run once per instance.
Timer actions
Start timer
Set a new timer, or if the timer exists, re-start it with
new options. Duration is the time until On timer
triggers. If Type is Once, On trigger will fire once and
not again until Start timer is used again; if Regular,
On timer will keep firing every Duration seconds. The
tag allows multiple timers to run at once. The
corresponding On timer condition must use the same
tag.
Stop timer
Stop a timer with a specific tag. On timer will no
longer trigger after this action.
Timer expressions
CurrentTime(tag)
The time in seconds since On timer last triggered, for
a timer with a specific tag.
Revision 3 Page 390/765
Duration(tag)
The duration in seconds for a timer with a specific
tag.
TotalTime(tag)
The time in seconds since a timer with a specific tag
was started with the Start timer action. This is only
useful with regular timers, since it will always equal
the CurrentTime expression for one-off timers (after
which they fire and the timer no longer exists, so
these expressions return 0).
If the target leaves the turret's range, the turret will lose
the target and stop firing. If another target is already in
range, it will immediately acquire that; otherwise it will
simply wait until the next target enters range. Also note
if Target mode is set to Nearest, the turret may switch
to another target before the current target leaves range,
if the new target comes closer than the existing target.
Predictive aim
A useful feature of the Turret behavior is the ability to
use predictive aim. For an interactive demonstration of
this see Example: Turret predictive aim in the Start
dialog.
Turret properties
Range
The range, in pixels, that the turret can detect targets
in. Any targets further away from the turret than this
distance will be ignored.
Rate of fire
The rate at which to trigger On shoot, when the turret
has both acquired a target and rotated to point in the
direction of the target.
Rotate
Whether to automatically set the object's angle
according to the angle of the turret.
Rotate speed
The speed at which the turret can rotate towards
targets, in degrees per second.
Target mode
If First in range, the turret will always track the same
target until it leaves range, even if other targets come
in range. If Nearest, the turret may switch to a
different target before its current target leaves range,
Revision 3 Page 394/765
if another target comes closer.
Predictive aim
Whether to enable predictive aim or not. If enabled,
you must set the correct Projectile speed for the
predictive aim to work correctly. For more information
see the section on Predictive aim above.
Projectile speed
If Predictive aim is enabled, this must be set to the
projectile speed in pixels per second for the predictive
aim to work correctly. For more information, see the
section on Predictive aim above.
Initial state
Whether the behavior is initially enabled or disabled.
If disabled, it can be enabled at runtime using the Set
enabled action.
Turret conditions
Has target
True if the turret currently has a target acquired.
On target acquired
Triggered when the turret has no target, but acquires
one as it enters range.
Turret actions
Acquire target
Target a specific object if it is in range. If the object is
out of range, the action is ignored. If in range, the
turret will switch to targeting the given object, even if
it already has a different target. Note if Target mode
is Nearest, the turret may still immediately switch to a
nearer target.
Clear targets
Remove all targets added using the Add object to
target action. The turret will no longer target any
objects at all.
Revision 3 Page 396/765
Unacquire target
Tell the turret to forget its existing target, even if it is
in range. This frees it up to target a different object,
but it may choose to immediately target the same
object again unless the Acquire target action is used
immediately afterwards.
Set enabled
Enable or disable the behavior. If disabled, the
behavior will not detect targets, rotate the object, or
run any triggers.
Turret expressions
Range
RateOfFire
RotateSpeed
Retrieve the corresponding properties. For more
information, see Turret properties.
Not all objects use all the common features; some may
use only a few of the ones listed here. This is provided
as a reference for the features shown to you in
Construct 2 rather than describing any particular
plugin's features.
Common conditions
Common actions
Common expressions
Angle
Note angles in Construct 2 start with 0 degrees facing
right and increment clockwise.
Is between angles
True if the object's current angle is between the two
given angles in degrees. The first and second angles
must be in clockwise order. That is, Is between 0 and
45 degrees is true if the object is in a 45 degree area,
but Is between 45 and 0 degrees is true if the object
is in the 315 degree area from 45 degrees through 0
degrees.
Is clockwise from
True if the object's current angle is clockwise from
the given angle in degrees. Invert to test if the object
is anticlockwise from the given angle. For example,
an object at 45 degrees is clockwise from 0 degrees,
but an object at 0 degrees is anticlockwise from 45
Revision 3 Page 403/765
degrees.
Is within angle
True if the object's current angle is within a number of
degrees of another angle. This is more reliable than
testing if the object's angle exactly equals an angle,
e.g. Is within 0.5 degrees of 90 degrees is probably
better than Angle equals 90 degrees, since there are
many cases an object can be very close to, but not
exactly, 90 degrees.
Appearance
Compare opacity
Compare the object's current opacity, from 0
(transparent) to 100 (opaque).
Is visible
True if the object is currently visible. Invert to test if
invisible. This only tests the visibility set by the Set
visible action; it is not affected by the object being
offscreen, having 0 opacity, or being on an invisible
layer.
Instance variables
Compare instance variable
Compare the current value of one of the object's
instance variables.
Pick highest/lowest
Pick the single instance with the highest or the lowest
instance variable value of all the instances. Note this
still only picks a single instance even if multiple
instances have the same highest or lowest value; in
this case an arbitrary instance is selected.
Misc
On created
On destroyed
Triggered for each instance that is created or
destroyed during the running of the game. On
created is also trigged for each object already on a
layout when the layout starts. For example, a one-
shot particle effect could be spawned every time an
object is created, and an explosion created every time
the object is destroyed. These conditions are
analogous to constructors and destructors in
traditional programming languages (commands which
run at the creation and destruction of an object). Be
careful not to create an object of the same type in an
On created event (e.g. On Sprite2 created: create
Sprite2) since this will create an infinite loop and
cause the game to hang.
Pick nearest/furthest
Pick the instance either nearest or furthest from a
given position in the layout.
Compare X
Compare Y
Compare the object's current position in the layout, in
pixels. Note that objects can be positioned between
pixels, e.g. at (5.5, 10.33333). Because of this it's
usually a bad idea to rely on an object being at an
exact position.
Is on-screen
True if any part of the object's bounding box is within
the screen area. This is not affected by the object's
visibility or opacity.
Is outside layout
Revision 3 Page 406/765
True if the entire object's bounding box is outside the
layout area.
Z Order
Is on layer
Pick all instances on a given layer, specified either by
its name or zero-based index.
Pick top/bottom
Pick either the top-most or bottom-most instance,
taking in to account layers and Z index. For example,
the instance at the front of the top most layer is the
top instance.
Angle
Note angles in Construct 2 start with 0 degrees facing
right and increment clockwise.
Rotate clockwise
Rotate the object a number of degrees clockwise.
Rotate counter-clockwise
Rotate the object a number of degrees counter-
clockwise.
Set angle
Set the object's angle in degrees, from 0 to 360. 0
degrees is facing right and angles increment
clockwise.
Appearance
Not all objects support the actions relating to effects. For
more information see Effects.
Set opacity
Set the object's opacity (or 'semitransparency'), from
0 (transparent) to 100 (opaque).
Set visible
Set the object visible or invisible (hidden).
Instance variables
Add to
Subtract from
Modify a number instance variable.
Set
Set a number or text instance variable.
Set boolean
Set a boolean instance variable, which can hold
either a true or false value.
Toggle boolean
Toggle a boolean instance variable, which flips it from
true to false or vice versa.
Misc
Destroy
Remove the object from the game.
Revision 3 Page 410/765
Set from JSON
Set the state of this object from a string of data in
JSON format. This must come from a prior use of the
AsJSON expression.
Move forward
Move the object a number of pixels forward at the
object's current angle.
Set width
Set height
Set size
Set the object's current size in pixels.
Set X
Set Y
Set position
Set the object's current position in the layout, in
pixels. The origin (0,0) is the top-left of the layout and
the Y axis increments downwards.
Z Order
Move to bottom
Move to top
Position the object either at the bottom or top of its
current layer.
Move to layer
Move the object to the top of a given layer, either by
its name or zero-based index. If the object is already
on the given layer this action has no effect.
Move to object
Move the object next to another object in the Z order.
You can choose to place the object to be placed in
front or behind another object. If the target object is
on a different layer, the object will also be moved to
the target object's layer and then Z ordered next to it.
Angle
Angle
The object's current angle, in degrees. 0 degrees is
facing right and angles increment clockwise.
Appearance
Opacity
The object's current opacity (semitransparency), from
0 (transparent) to 100 (opaque).
Misc
AsJSON
Save the object state to a string of data in JSON
format, and return it. This can be downloaded or
otherwise stored, and later the state of the object
restored using the Set from JSON action.
Revision 3 Page 413/765
Count
The number of instances of the object type.
PickedCount
The number of instances meeting the event's
conditions. For example, if the event has the
condition "Mouse is over Sprite", [Link]
will return the number of Sprite instances that the
mouse is over.
IID
Return the instance's index ID (IID). See common
features.
UID
Return the instance's unique ID (UID). See common
features. #Size & Position#
BBoxLeft
BBoxRight
BBoxTop
BBoxBottom
Return the layout co-ordinates of the object's axis-
aligned bounding box. This is the smallest unrotated
box that completely encloses the object, taking in to
account any rotation or stretching.
Width
Height
Return the size of the object in pixels.
Revision 3 Page 414/765
ImagePointX
ImagePointY
Return the position of one of the object's image
points in layout co-ordinates. Either the image point's
name or its number can be passed.
X
Y
Return the object's position in the layout, in pixels.
The origin (0,0) is at the top-left of the layout and the
Y axis increments downwards.
Time
dt
Return delta-time according to the object's own
timescale. See Delta-time and framerate
independence for more information.
Z Order
LayerName
The name of the layer the instance is currently on.
LayerNumber
The zero-based index of the layer the instance is
currently on.
ZIndex
Get the zero-based index of the Z order of this
Revision 3 Page 415/765
instance within its current layer. 0 is the bottom
instance, increasing up to the top instance.
9-patch properties
Image
Click the Edit link, or double-click the object in the
Layout View, to edit the source image used for the 9-
patch.
Left margin
Right margin
Top margin
Bottom margin
The margins of each side of the 9-patch, in pixels.
See the image above for a visualisation of how these
Revision 3 Page 418/765
margins are used to determine the nine sections.
Edges
Use Stretch to stretch each edge patch to the size of
the object. Use Tile to repeat the edge patches
instead.
Fill
Use Stretch to stretch the fill patch to the size of the
object. Use Tile to repeat the fill patch inside the
object instead, like a Tiled Background. Use
Transparent if you don't want a fill image.
Initial visibility
Set whether the object is visible or invisible at the
start of the layout.
Hotspot
Choose the position of the hotspot (or origin) of the
object relative to its unrotated bounding rectangle.
Seams
To ensure seamless rendering under all
circumstances, by default the patches internally
overlap by 1 pixel (using the Overlap setting).
However for semi-transparent patches this can cause
a visible seam; in this case it is preferable to use the
Exact setting instead.
Setting up
To get started with the plugin, follow these steps:
Exporting
Remember to set the Test mode property to No before
Revision 3 Page 421/765
publishing.
Plugin ID:
[Link]
AdMob properties
Overlap
Whether banner ads should overlap the game, or
Revision 3 Page 422/765
reduce the game viewport size to fit the ad alongside.
Test Mode
Display ads for testing use only. Be sure to set to No
before publishing.
Banner ID / Interstitial ID
(for various platforms) Paste in the Ad Unit IDs from
your AdMob account in to these properties.
AdMob conditions
Is showing banner ad
True if currently displaying a banner ad.
Is showing interstitial
True if currently displaying an interstitial ad.
On banner ad received
Triggered after Preload banner ad when the ad has
been downloaded and is ready to be displayed.
On interstitial dismissed
Triggered when an interstitial ad is closed.
On interstitial presented
Triggered when an interstitial ad is first displayed.
On interstitial received
Triggered after Preload interstitial when the ad has
Revision 3 Page 423/765
been downloaded and is ready to be displayed.
AdMob actions
Hide banner ad
Hide any currently showing banner ad.
Preload banner ad
Start downloading a banner ad. When it is ready, On
banner ad received is triggered, and then the ad can
be displayed without any delay.
Preload interstitial
Start downloading an interstitial ad. When it is ready,
On interstitial received is triggered, and then the ad
can be displayed without any delay.
Reload banner ad
Reload a currently showing banner ad, replacing it
with a different one.
Reload interstitial
Reload a currently showing interstitial ad, replacing it
with a different one.
Show banner ad
Show a banner ad at a given position and size.
Show interstitial
Show an interstitial ad which has been preloaded.
Revision 3 Page 424/765
Alternatively if nothing has been preloaded, it will
download an interstitial and then show it when ready.
AdMob expressions
The AdMob object has no expressions.
Tags
A different tag can be provided for each request. This is
a simple string you set to tell apart different requests.
For example, on startup you may request both [Link]
with tag "foo" and [Link] with tag "bar". When the first
request completes, On "foo" completed triggers; when
the second request completes, On "bar" completed
triggers. Requests can complete in a different order to
the order they were made, so without tags it would be
impossible to tell which request was completing.
Access-Control-Allow-Origin: [*]
This will enable AJAX requests from any domain, but
you should still be aware of the possible security
implications of this. For more information on cross-
domain requests see HTTP access control on MDN.
In [Link]
When exporting desktop applications with [Link], the
AJAX object can also load files from the application
folder. Simply use the Request URL action and enter
the name of a file in the same directory as the
application, e.g. "[Link]". Note if a project file
exists with the same name, this will always load the
project file instead.
MIME types
AJAX requests for files on your own server requires that
your server has the correct MIME types set up.
AJAX conditions
On completed
Triggered when a request with the same tag has
completed successfully. The LastData expression
contains the response.
On error
Triggered when a request with the same tag has
failed. This can be for a number of reasons, such as
the server being down or the request timing out. (The
LastData expression is not set since there is no
response.)
On any error
Triggered when any request has failed. The Tag
expression identifies the request.
On progress
For long running requests (e.g. downloading a large
file), On progress triggers periodically and updates
the Progress expression with the state of the request.
This is useful for making progress bars for AJAX
requests.
AJAX actions
Override MIME type
In some cases you may wish to interpret the server's
response with a different MIME type to the one the
server indicates. For example a misconfigured server
may return a text file with the wrong character set,
Revision 3 Page 429/765
and you want to force the response to be interpreted
as UTF-8. In this case you could override the MIME
type as text/plain; charset=utf-8 to avoid garbling the
text. This action only applies to the next AJAX
request that is made, after which the MIME type will
be set back to the default setting of accepting what
the server response indicates.
Post to URL
Send a request with data to a URL and retrieve the
response. A tag is provided to match it up with the On
completed, On progress and On error triggers.
Construct 2 does not automatically URL encode the
post data - use the URLEncode system expression
to ensure the data is in the correct format for posting.
Note post data is in the same format as a query
string, e.g. "foo=1&bar=2". The method can also be
specified: by default it is POST, but for some APIs
you may need to change this to PUT, DELETE or
another HTTP method.
Request URL
Send a GET request to retrieve the contents of a
URL. A tag is provided to match it up with the On
completed, On progress and On error triggers.
Set timeout
Set the amount of time a request has to complete in
seconds; if the timeout expires without the request
completing successfully, it will instead fail and trigger
On error. This action only affects subsequent
requests, and does not affect any requests that have
already started. If the timeout is set to -1 it restores
the default browser timeout.
AJAX expressions
LastData
The contents of the last response. This is set in the
On completed trigger. If used in a different event, it
contains the response of the last completed request.
The tokenat system expression may be useful to split
simple responses
Progress
Return the progress of the AJAX request in an On
progress event. The progress is represented as a
number from 0 to 1, e.g. 0.5 for half completed.
Tag
Revision 3 Page 431/765
The tag of the AJAX request in a trigger. This is
useful to identify requests in On any completed or
On any error.
About Arrays
Array supports up to three dimensions. For example, a
simple list of ten values would be a 10 x 1 x 1 array.
Note that you should not set a size of 0 on any of the
dimensions else the entire array becomes empty; it is
correct to have a size of 1 on unused dimensions.
Manipulating arrays
A one-dimensional array, sized N x 1 x 1, serves as a
simple list of N values. The actions in the Manipulation
category (e.g. Push, Pop) allow one-dimensional arrays
to be used like other data structures. (These actions
work with multidimensional arrays, but are intended for
the one-dimensional case.)
Array properties
Width
Revision 3 Page 434/765
(X dimension)
Height
(Y dimension)
Depth
(Z dimension) The size of the array. If you want a
one-dimensional array (i.e. a list of values), use A x 1
x 1. If you want a two-dimensional array (i.e. a grid of
values) use A x B x 1.
Array conditions
Compare at X
Compare at XY
Compare at XYZ
Compare a value at a position in the array. Indices
are zero-based. All values outside the array return
the number 0. If Compare at X is used, the Y and Z
indices are 0. If Compare at XY is used, the Z index
is 0.
Compare size
Compare the size of one of the array dimensions,
which is the number of elements on that axis.
Contains value
Searches the entire array to check if any of the
elements contains the given value. For example, you
can use this to test if the string "sword" is stored
anywhere in the array.
Is empty
Test if the array is empty. The array is empty when
the total number of elements is zero, calculated as
width x height x depth. Therefore the array is empty
when any axis has a size of zero. This can be useful
when using Array as a data structure (e.g. when
pushing and popping values).
Array actions
Clear
Set every element in the array to the number 0.
Set at X
Set at XY
Set at XYZ
Write a value at a position in the array. Indices are
zero-based. Writing to values outside the array has
no effect. If Set at X is used, the Y and Z indices are
0. If Set at XY is used, the Z index is 0.
Revision 3 Page 436/765
Set size
Set the dimensions of the array. Values are
preserved, but if the new array is smaller it is
truncated. If the new array is larger, new elements
are set to store the number 0. If any of the
dimensions are 0 the entire array is empty, so usually
all the dimensions are at least 1.
Download
Invokes a browser download of a file containing the
Array's contents in JSON format. This is intended for
offline development, e.g. creating level editors.
Load
Load the contents of the array from a string in JSON
format. This must have been retrieved from either the
Download action or the AsJSON expression. It could
also be retrieved dynamically from the AJAX object.
Push
Add a new value either to the beginning (front) or end
(back) of an axis. Since the Array is a 3D cube of
values, technically this inserts a new 2D plane of
elements all with the given value. However in 1D
arrays this adds a single element, and in 2D arrays it
inserts a new row of elements.
Pop
Delete the value at either the beginning (front) or end
(back) of an axis. Since the Array is a 3D cube of
Revision 3 Page 437/765
values, technically this removes a 2D plane of
elements. However in 1D arrays this removes a
single element, and in 2D arrays it removes a whole
row of elements.
Insert
Insert a new value at a specific index on an axis.
Since the Array is a 3D cube of values, technically
this inserts a new 2D plane of elements all with the
given value. However in 1D arrays this adds a single
element, and in 2D arrays it inserts a new row of
elements.
Delete
Delete the value at a specific index on an axis. Since
the Array is a 3D cube of values, technically this
removes a 2D plane of elements. However in 1D
arrays this removes a single element, and in 2D
arrays it removes a whole row of elements.
Reverse
Reverse the order of elements on an axis. Note that
in multidimensional arrays this only reverses one
axis. For example reversing the X axis in a 2D array
will reverse the order of the columns while preserving
the contents of each column.
Sort
Sorts the order of elements on an axis in ascending
order. Note that in multidimensional arrays this sorts
based on the first element on the axis. For example
Revision 3 Page 438/765
sorting the X axis in a 2D array will sort the order of
the columns based on the elements at Y co-ordinate
0, while preserving the contents of each column.
Array expressions
At(X)
At(X, Y)
At(X, Y, Z)
Retrieve a value at a position in the array. Indices are
zero-based. Reading values outside the array returns
the number 0. If the Y or Z indices are not provided
then 0 is used.
CurX
CurY
CurZ
The current zero-based index for each dimension in a
For each element loop.
CurValue
The current value in a For each element loop. This is
a shortcut for [Link]([Link], [Link],
[Link]).
Width
Height
Depth
Return the size of each of the array's dimensions.
Front
Revision 3 Page 439/765
Shortcut to access the first value in the array, which
is the same as At(0, 0, 0).
Back
Shortcut to access the last value on the X axis, which
is the same as At([Link] - 1, 0, 0).
IndexOf
LastIndexOf
Searches the array X axis for a given value and
returns the index it is found at, or -1 if not found.
IndexOf finds the first matching element, and
LastIndexOf finds the last matching element.
AsJSON
Return the contents of the array as a string in JSON
format. This can later be loaded in to the array with
the Load action.
The Audio object plays back audio files that have been
imported to the project. It must be inserted to each
project that needs to use audio playback. Audio files can
be imported to a project by right-clicking the Sounds or
Music folders in the Project Bar and selecting Import...,
which brings up the Import Audio dialog. See the
relevant sections for more information on the steps
involved to import audio files.
Preloading sounds
The Preload sounds project property determines
whether sounds (excluding music) are downloaded
Revision 3 Page 441/765
while the loading bar is showing. Preloading sounds
means there is more to download before the game can
start, but all sound effects can play immediately once it
starts. If sounds are not preloaded, the game starts
sooner since it did not need to download any sounds,
but sounds will be downloaded on-demand during the
game. In other words, nothing is downloaded until a
Play action starts playing an audio file. Then it starts
downloading and will play when finished downloading.
This also helps minimise the bandwidth requirement on
the server since unused audio is never downloaded.
However, it can introduce a delay before audio plays for
the first time. The delay on first play is a one-off,
because after the first play the sound is already
downloaded and can be played immediately if played a
second time.
MIME types
Make sure after exporting your server has the correct
MIME types set up, otherwise audio may fail to play in
some browsers.
Mobile limitations
Safari on iOS and Chrome for Android share a limitation
Revision 3 Page 443/765
in playing music. While sound effects can be played at
any time, music is only allowed to start playing when the
user touches the screen. This is a limitation in the
browsers themselves. As a result, if you play music on
the start of layout, you may find in these browsers it
does not actually start until the next touch.
Advanced audio
The Audio object supports some advanced features,
such as positioned sounds and convolution effects.
However these depend on the Web Audio API which is
not supported in all browsers. You can detect if these
features are available using the Advanced audio
supported condition. If it is not supported, the advanced
audio features will not change the sound in any way.
Audio properties
Timescale audio
The game timescale can be used to speed up or slow
down playback of the game, for effects like slow-
motion. See Delta-time and framerate independence
for more information. This property controls whether
or not audio is affected by the game's timescale. Off
will play back audio the same regardless of the
timescale. On (sounds only) will play back audio from
the Sounds project folder at a different rate
depending on the timescale, but will always play back
audio from the Music project folder at the same rate.
On (sounds and music) will play back all audio at a
different rate depending on the timescale. Some
browsers may not support audio timescaling at all;
test on multiple browsers to establish support. Also,
different browsers may use different time-stretching
algortihms for audio. Browsers can either alter pitch,
going to lower pitch for lower time scales like a tape
machine playing at a different speed; alternatively
they can change the playback speed without
affecting the pitch. Test on multiple browsers to
establish the exact effect achieved.
Revision 3 Page 445/765
Save/load
When using savegames, what audio state should be
saved and restored. If All, all sound and music is
saved and restored upon loading a game, so that
music and sound effects keep rewinding to the same
point they were at upon saving. Sounds only will only
restore the sound effects playing at the time of the
save, and allow music to keep playing through
unaffected when loading a game. Music only
conversely only restores the music playing at the time
of the save, and allows sound effects to keep playing
through unaffected when loading a game. None does
not save or load any audio state at all. Audio will be
completely unaffected when loading a game, and any
playing music and sound effects will continue to play
out to their end.
Play in background
If No, then switching browser tab, minimising the
browser window, switching to a different mobile app,
or otherwise hiding the window will pause all audio
and resume it when switching back. This is intended
to avoid annoying the user with continued music
playback when deciding to do something else, and
also helps save battery on mobile. However for some
types of app such as music players it may be
desirable to keep music playing in these cases, in
which case setting to Yes allows continued audio
playback even when in the background.
Panning model
Revision 3 Page 446/765
How positioned sounds are panned. HRTF uses a
realistic model of human hearing, whereas equal
power is a simple method that preserves the overall
power in a stereo channel.
Distance model
The formula to determine volume reduction of
positioned sounds relative to the distance to the
listener. The options are: Linear, using the equation 1
- rolloffFactor [] (distance - refDistance) /
(maxDistance - refDistance)* Inverse, using the
equation refDistance / (refDistance + rolloffFactor []
(distance - refDistance))* Exponential, using the
equation pow(distance / refDistance, -rolloffFactor).
Listener Z height
The height of the listener above the layout, in layout
pixels, used to determine relative volume and
panning of positioned sounds. A low Z height will
have intense changes over small distances, whereas
a high Z height will have smaller changes over larger
distances.
Reference distance
The distance at which the volume of positioned
sounds begins to reduce. For best results this should
be at least as much as the Listener Z height.
Maximum distance
The maximum distance in pixels beyond which
positioned sounds no longer reduce their volume.
Revision 3 Page 447/765
Roll-off factor
How quickly the volume reduces as positioned
sounds move away from the listener. A high roll-off
factor means sounds get quieter quickly, whereas a
low roll-off factor means sounds will not lose much
volume.
Speed of sound
The speed of sound, in layout pixels per second,
used for determining the doppler shift of positioned
sounds.
Doppler factor
How much pitch shift occurs due to the doppler
effect. A value of 0 will disable doppler effects
completely, and values greater than 1 will exaggerate
the doppler effect.
Audio conditions
Advanced audio supported
If true, the current browser supports all the features
in the Advanced categories of the Audio object. If
false, none of these features will have any effect on
playback.
Is any playing
True if any audio is currently playing.
Is silent
Revision 3 Page 448/765
True if the object has been set in to silent mode using
the Set silent action.
Is tag playing
True if any audio with a given tag is currently playing.
On ended
Triggered when a sound with a given tag finishes
playing. This is not triggered for looping sounds.
Preloads complete
True when all audio preloaded with one of the preload
actions has finished loading.
Preload
Preload (by name)
Start downloading an audio file so it has no delay
before playing. See the section Preloading sounds
above for more information. Audio does not have to
be preloaded before playing - it is optional and only
serves to possibly reduce the delay before audio
plays for the first time. Once all audio preloaded with
this action finishes loading, the On preloads
complete trigger fires. Note if the project Preload
sounds property is Yes, there is no point preloading
any sounds, since they will always be loaded before
the game starts - in this case it only makes sense to
preload music.
Seek to
Seek a currently playing sound to a different location
in the audio file. The time to seek to is given in
seconds.
Set looping
Set a sound either looping (repeating when it
finishes) or not looping (stopping when it finishes).
Not all browsers currently support this feature; test on
multiple browsers to identify support.
Set paused
Pause or resume some audio by its tag.
Set silent
Enable, disable or toggle Silent mode. In silent mode
all currently playing sounds are muted and no new
sounds will play. This is useful for quickly creating an
audio toggle on a title screen.
Set volume
Change the volume of a sound. The volume is given
in decibels (dB). A volume of 0 dB is original volume,
and below 0 dB attenuates the sound. Note
amplification is not supported. For example, entering
a value of -10 plays the audio back 10 dB quieter
(about half as loud). Note it is best to set the initial
volume in the Play action instead of setting it with this
Revision 3 Page 451/765
action immediately after playing, since that can
sometimes cause a moment of playback at the wrong
volume.
Stop
Stop a sound playing immediately.
Stop all
Stop all currently playing sounds.
Play at position
Play at position (by name)
As per the Play at object action, but the sound does
not move. It is simply played at a position and angle
in the layout. Doppler effects can still occur based on
the listener's velocity relative to the sound.
Set listener Z
Set the Listener Z property of the audio object.
Revision 3 Page 452/765
Audio actions: Effects
A selection of well-known audio effects can be added
using the "Add effect" actions. Each tag has its own
effect chain, and multiple effects can be added to a tag.
All audio played with the given tag is then processed by
the effect chain. This can be used to create
environmental effects and other creative audio features.
Audio signal processing is a complex topic and
somewhat out of the scope of this manual, so it will not
be detailed exhaustively here. Anyone with light
experience in audio recording or production should
already be familiar with all the effects available. For
interactive examples, search for Audio in Construct 2's
Start dialog. A brief summary of each effect is provided
below:
Audio expressions
AnalyserFreqBinAt(Tag, Index, Bin)
Get the magnitude of energy in an analyser's
frequency bin. Advanced audio must be supported,
and an analyser effect already added to a tag. Index
must be the index of the effect (for example, 0 if the
analyser is the first added effect for that tag, 1 if the
second added effect, and so on). Bin is the
frequency bin number to retrieve from, up to
AnalyserFreqBinCount.
AnalyserFreqBinCount(Tag, Index)
Get the number of frequency bins returned by an
analyser. Advanced audio must be supported, and an
Revision 3 Page 455/765
analyser effect already added to a tag. Index must be
the index of the effect (for example, 0 if the analyser
is the first added effect for that tag, 1 if the second
added effect, and so on).
AnalyserPeakLevel(Tag, Index)
Get the peak level of audio in the last FFT window
from an analyser. Index must be the index of the
effect (for example, 0 if the analyser is the first added
effect for that tag, 1 if the second added effect, and
so on). The value is returned in dBFS (0 dB for peak
level, and negative values for lower). If you intend to
use this value it is recommended to use an FFT size
of 1024, because at a system sample rate of 44.1
KHz the value will update about 43 times a second.
Games usually run at 60 FPS, and smaller FFT sizes
may cause FFT windows to be missed since they
change faster than the framerate.
AnalyserRMSLevel(Tag, Index)
Get the RMS level of audio in the last FFT window
from an analyser (the square root of the average of
the squared sample values). Index must be the index
of the effect (for example, 0 if the analyser is the first
added effect for that tag, 1 if the second added effect,
and so on). The value is returned in dBFS (0 dB for
peak level, and negative values for lower). If you
intend to use this value it is recommended to use an
FFT size of 1024, because at a system sample rate
of 44.1 KHz the value will update about 43 times a
second. Games usually run at 60 FPS, and smaller
Revision 3 Page 456/765
FFT sizes may cause FFT windows to be missed
since they change faster than the framerate.
EffectCount(Tag)
Get the number of effects in the effect chain for a tag.
CurrentTime
Get the audio clock time in seconds. Where
supported, this is returned from the audio hardware,
providing the correct time against which to schedule
audio playback. It is important to use this value to
calculate playback times in the Schedule next play
action.
Duration(Tag)
Get the duration in seconds of an audio sample with
a tag.
MasterVolume
Return the current master volume set using the Set
master volume action.
PlaybackTime(Tag)
Get the current playback time in seconds of a sound
with a tag. This starts at 0 and counts up to the
duration, except for looping sounds which keep
counting up past the duration.
SampleRate
Return the audio output sample rate in Hz, typically
44100 or 48000.
Revision 3 Page 457/765
Volume(Tag)
Get the volume set for a sound with a tag.
Browser conditions
Cookies enabled
True if the user has cookies enabled in their browser.
(Typically it is rare for them to be disabled since
many web sites rely on cookies to work properly.)
Is online
True if the browser currently has an active
connection to the internet. Construct 2 games can
work offline - see Offline games for more information.
Revision 3 Page 460/765
On resized
Triggered when the browser window displaying the
game is resized. This includes when changing
orientation on a mobile device. The system
expressions WindowWidth and WindowHeight will
update to reflect the new size if a fullscreen mode is
in use.
On went online
On went offline
Triggered if the connection to the internet is becomes
available or unavailable during the running of the
game. This is common on mobile devices which may
be moving in and out of signal areas. The Is online
condition also changes to reflect the connection
status.
Is portrait/landscape
Determine if the current display is portrait (height is
greater than width) or landscape (width is greater
than height). This is performed by making a simple
check on the window size of the browser, so also
returns accordingly on a desktop browser depending
on its dimensions.
On back button
Triggered when the user presses the device's 'Back'
button. Note not all devices have this button (e.g. iOS
devices only have a 'Home' button) and not all
platforms support this trigger.
Revision 3 Page 461/765
On menu button
Triggered when the user presses the device's 'Menu'
button. Note not all devices have this button (e.g. iOS
devices only have a 'Home' button) and not all
platforms support this trigger.
On search button
Triggered when the user presses the device's
'Search' button. Note not all devices have this button
(e.g. iOS devices only have a 'Home' button) and not
all platforms support this trigger.
Is downloading update
True if the game is running from cache, but
downloading an updated version in the background.
This can be used to implement a simple auto-updater.
See Offline games for more information.
On update ready
Triggered when the game is running from cache, but
an updated version has finished downloading in the
background. If the user is still on the game's menu or
title screen, you may wish to prompt them to refresh
the page (or just do it automatically) so the new
version is loaded. See Offline games for more
information.
Is fullscreen
True if the browser is running in fullscreen mode.
Page is visible
Revision 3 Page 462/765
True if the page the HTML5 game is running on is
currently visible. The page counts as hidden if the
window is minimised, the page is in a different tab to
the one being viewed, or on a mobile device when the
app goes in to the background. When the page is
hidden the game automatically pauses.
On suspended
On resumed
Triggered when the page's visibility changes, or when
a mobile app is going in to the background or
foreground. When invisible or in the background the
app is suspended: all events stop running and all
audio is muted.
Browser actions
Execute Javascript
Run a string of Javascript code. Great care is
necessary to use this correctly - see the section
'Risks with Javascript string execution' above.
Start group
End group
Start or end a group in the browser error console.
Groups appear indented, and the browser may give
Revision 3 Page 463/765
the option to expand/collapse the group easily.
Groups can optionally be named. To create a group,
use Start group, then a series of Log actions, then
the End group action.
Log
Log a message, warning or error to the browser error
console. This can be useful for debugging, testing
and diagnostics.
Vibrate
Vibrate the device with a given pattern, if the
device/platform supports vibration. The pattern is
given as a comma-separated list of times in
milliseconds, alternating between vibrate time and
waiting. For example the string "200,100,200"
specifies a 200ms vibration, 100ms pause, then
another 200ms vibration. This allows a single action
to specify a whole vibrate pattern.
Go back
Go forward
Move through the browser navigation history as if
clicking the Back and Forward buttons on the
browser.
Go home
Navigate to the browser's set homepage.
Go to URL
Navigate to a given URL. Note this uses the same
Revision 3 Page 464/765
window/tab as is showing the HTML5 game, so this
action will end the game. The Target can be used to
select which frame to redirect, which is only useful if
the game is displayed within a frame (e.g. an iframe
embed), and the frame has permission to redirect the
parent frame (i.e. it is not sandboxed). Possible
targets are: Self: redirect only the frame that is
currently showing the game. Parent: redirect the
parent frame. Top: redirect the top level frame (only
different to the parent if more than one frame is used)
Invoke download
Invoke a URL as a file download in the browser.
Even if this points to a web page or document, it will
be downloaded as a file in the browser interface. The
URL can point to any address on the Internet, or it
can be the name of any imported project file, or it can
be a data URL (useful for downloading canvas
snapshots). The filename parameter allows you to
choose the filename the browser gives to the
download, which can be different to the name of the
resource being downloaded.
Reload
Force the page to refresh. This effectively restarts
the game.
Alert
Bring up a simple 'alert' message box.
Blur
Unfocus the browser window.
Cancel fullscreen
Return to windowed mode if the browser is currently
in fullscreen mode.
Close
Close the current window, if the script has permission
to do so.
Focus
Focus the browser window.
Lock orientation
Unlock orientation
Lock the display of the game to a portrait or
landscape mode only, if the current platform supports
Revision 3 Page 466/765
this. This only has effect on mobile devices. The
game may have to already be displaying in fullscreen
(using the Request fullscreen action) before the
orientation can be locked. Unlocking the orientation
restores whatever behavior was set before locking,
such as automatically changing orientation
depending on the way the device is being held.
Request fullscreen
Request that the browser enter fullscreen mode. Note
the browser may ignore this request unless the action
is in a user-initiated event, such as a mouse click,
key press, touch event or button press. The
fullscreen modes that can be entered correspond to
the Fullscreen in browser project property. For more
information see supporting multiple screen sizes.
Note not all platforms support requesting fullscreen -
use the Supports requesting fullscreen condition to
check for availability.
Browser expressions
BatteryLevel
Return the current battery charge level from 0
(discharged) to 1 (fully charged). For example, to get
the battery level as a percentage, use
round([Link] [] 100)*. If the device
does not have a battery or the level is unknown,
returns 1.
BatteryTimeLeft
Revision 3 Page 467/765
If the device has a battery and the remaining time is
known, returns the estimated time in seconds until
the system will have to shut down due to battery
discharge. If no battery is present or the time left is
unknown, returns infinity.
ExecJS
Run a string of Javascript code, and return the result
if it is a string or a number. Great care is necessary to
use this correctly - see the section 'Risks with
Javascript string execution' above.
Language
Get the browser's current language setting, e.g. en-
US.
Name
Get the name the browser reports for itself. This may
be inaccurate for backwards compatibility reasons,
e.g. Google Chrome reports its name as Netscape.
Platform
Get the current platform the browser reports itself
running on, e.g. Win32 for Windows.
Product
Get the product the browser reports for itself. This
may be inaccurate for backwards compatibility
reasons, e.g. Google Chrome reports its product as
Gecko.
Revision 3 Page 468/765
UserAgent
Return the full user agent string for the browser, e.g.
Mozilla/5.0 (Windows NT 6.1; WOW64)
AppleWebKit/535.7 (KHTML, like Gecko)
Chrome/[Link].
Vendor
Get the vendor the browser reports for itself, e.g.
Google Inc. for Google Chrome.
Version
Get the version the browser reports for itself as a
string. This can simply be a subset of the user agent
string.
Bandwidth
The estimated available bandwidth in megabits per
second of the detected connection technology. Note
this may not be a reliable value - for example if the
browser detects it is connected via Ethernet it may
report the estimated Ethernet bandwidth, whereas
further up the network is a router with a lower
bandwidth. If the bandwidth is unknown, it returns
positive infinity.
ConnectionType
The type of connection technology in use if it is
known. This can be "bluetooth", "cellular",
"ethernet", "wifi", "wimax", "other", "unknown" or
"none" (indicating offline mode).
Revision 3 Page 469/765
DevicePixelRatio
The number of physical display pixels per CSS pixel.
This can be a useful indicator of display density. For
example, 'retina' displays report the value as 2,
whereas ordinary displays report the value as 1.
ScreenWidth
ScreenHeight
Retrieve the dimensions of the entire device screen.
This is the complete display area available to the
operating system.
Title
The current HTML document's title.
Domain
The current domain, e.g. [Link].
Hash
The string after the hash at the end of the URL,
including the hash. For example, if the current URL is
[Link] this
returns [#]teapot.
PathName
The path relative to the domain in the URL. For
example the path name of
[Link] is
/mygame/[Link].
QueryParam
Return a query string parameter by name. For
example, if the URL ends with [Link]?
foo=bar&baz=wan, QueryParam("foo") returns bar
and QueryParam("baz") returns wan.
QueryString
Return the full URL query string including the
question mark. For example, if the URL ends with
[Link]?foo=bar&baz=wan, this returns ?
foo=bar&baz=wan.
Referrer
Get the previous page that linked to this page, if any.
URL
Get the complete current URL in the browser address
bar, including the protocol.
Button properties
Type
Either Button for a push-button or Checkbox for a
checked/unchecked control. See the image above for
a demonstration of both types.
Text
The text appearing on the button face or checkbox
label.
Tooltip
A tooltip that appears in most browsers if the user
Revision 3 Page 473/765
hovers the mouse over the button and waits. Leave
blank for no tooltip.
Initial visibility
Whether or not the button is shown on startup. If
Invisible, the button must be shown with the Set
visible action.
Enabled
Whether the button is initially enabled. If No, the
button will be greyed out and cannot be pushed.
ID
(optional) An optional id attribute for the element in
the DOM (Document Object Model). This can be
useful for accessing the element's value from
external scripts, or styling with CSS in the HTML
page.
Checked
If Type is Checkbox, this is the initial check state of
the control.
Revision 3 Page 474/765
Button conditions
Is checked
If Type is Checkbox, is true if the control is currently
checked.
On clicked
Triggered when the user pushes the button or
checks/unchecks the control, either by keyboard,
mouse or touch input.
Button actions
Set CSS style
Set a CSS (Cascading Style Sheets) style on the
Button element. For more information, see the
section Styling Button objects. Note that if the Auto
font size property is set to Yes, any changes to the
font-size property will be overridden.
Set checked
If Type is Checkbox, set the current check state of
the control.
Set enabled
Set the button enabled or disabled. When disabled,
the button appears greyed out and cannot be
pushed.
Set focused
Revision 3 Page 475/765
Set the input focus to the button.
Set text
Set the text on the button face.
Set tooltip
Set the text that appears for the button tooltip. Leave
blank for no tooltip.
Set unfocused
Remove the input focus from the button.
Toggle checked
If Type is Checkbox, toggles the check state of the
control.
Button expressions
The Button object does not have any of its own
expressions.
Example
Suppose the number 100 is stored with the key "score",
and the string "Joe" stored with the key "name". The
result storage looks like the following table:
"name": "Joe"
"score": 100
Compare value
Compare the value stored for a key.
Has key
Check if a key exists in storage.
Is empty
True when there are no keys in storage.
Dictionary actions
Add key
Add a new key to storage, with a given value. If the
key already exists, its value is updated.
Clear
Remove all keys from storage, making the object
empty.
Set key
Update the value for a key which already exists. If the
key does not exist, this has no effect. (Unlike Add
key, the key will not be created.)
Download
(JSON) Invokes a browser download of a file
containing the Dictionary's contents in JSON format.
This is intended for offline development, e.g. creating
level editors.
Load
(JSON) Load all keys and values from JSON data
previously retrieved from the Dictionary object using
either the Download action or the AsJSON
expression.
Dictionary expressions
Get
Return the value stored for a key, e.g.
[Link]("score"). If the key does not exist, it
returns 0.
KeyCount
Return the number of keys in storage.
Revision 3 Page 479/765
CurrentKey
CurrentValue
In a For each key event, these return the key and its
value (respectively) for the current key being iterated.
AsJSON
Return the contents of the Dictionary object in JSON
format. This can be later loaded back with the Load
action, sent to a server via AJAX, saved to disk, and
so on.
Readiness
The Facebook object takes a moment to load on startup.
Do not attempt to use the Facebook object before On
ready has triggered or Is ready is true, otherwise the
actions will be ignored.
Logging in
The user must successfully log in with their Facebook
account before they can use any other features of the
Facebook object, such as posting to the user's wall.
This is done with the Log in action, and since login can
take a few seconds you must wait until On user logged
in triggers before using any other features.
Facebook Properties
App ID
The App ID given for your app in the Facebook
Revision 3 Page 482/765
Developers section.
App Secret
This is only necessary if you plan to use the Scores
API. Otherwise do not enter the app secret. The app
secret can be found in the Facebook Developers
section for your app and is currently necessary to
enable the Scores API.
Facebook conditions
Is ready
True if the Facebook object is ready to be used.
When false, the Facebook object is still loading the
necessary scripts and all actions will be ignored.
Is user logged in
True if the user is currently logged in with their
Facebook account.
On name available
Triggered shortly after On user logged in, when the
expressions to get the user's name are available.
On ready
Triggered when the Facebook object is ready to be
used. Before this triggers, the Facebook object is still
loading the necessary scripts and all actions will be
ignored.
On hi-score
Triggers once for each hi-score after the Request hi-
score board action. The HiscoreName, HiscoreRank
and Score expressions contain the current hi-score
information.
On score submitted
Triggers when the Publish score action has
successfully completed.
Facebook actions
Log in
Open a popup window requesting the user to log in.
Revision 3 Page 484/765
This can only be called in a user-input event, such as
a key press, button push, mouse click or touch
screen tap. The user may cancel at the log in screen
so logging in is not guaranteed to be successful. You
must provide a comma-separated list of permissions
to request. Some features of the Facebook plugin
depend on the user approving certain permissions.
Do not request permissions that your application
does not need. You can find documentation on the
available permissions in the Facebook developer's
guide.
Log out
Log the current user out from Facebook.
Publish link
Automatically publish a URL to the user's wall without
any prompt. Descriptions and a thumbnail image can
optionally be provided. This requires that the user
has logged in with the Publish to stream permission.
Publish score
Publish a numerical score to the hi-score board for
the game. This requires that the user has logged in
with the Publish scores permission. When the action
completes, it triggers On score submitted.
Facebook expressions
FirstName
The current user's first name. This is only set after
On name available triggers.
FullName
The current user's full name. This is only set after On
name available triggers.
LastName
The current user's full name. This is only set after On
name available triggers.
UserIDStr
The current user's ID, which can be used to
distinguish different users with the same name. This
is only set if the user is logged in. Note: although this
is a number, it is returned as a string since IDs can
be larger numbers than Javascript can express.
HiscoreName
The current hi-score board entry name. This is only
set in an On hi-score event.
Revision 3 Page 487/765
HiscoreRank
The current hi-score board entry rank, from 1 down to
the number of hi-score entries requested. This is only
set in an On hi-score event.
HiscoreUserIDStr
Return the user ID of the current hi-score board
entry. This is unique even if two people on the hi-
score board have the same name. Note: although
this is a number, it is returned as a string since IDs
can be larger numbers than Javascript can express.
Score
Either the current hi-score in an On hi-score event,
or the current user's score in On user top score
available.
Using files
Once a file has been selected, it can be accessed using
a URL. While many URLs reference web resources on
the Internet, the File Chooser plugin returns a special
URL that refers to the local file. This URL typically starts
with "blob:" (since the browser's term for an arbitrary set
of data is a "blob") followed by some kind of unique ID.
By accessing this URL the local file is accessed, without
using any Internet connection, so this also works offline.
The file URL can be used like any other URL. For
example, it can be requested by the AJAX object to load
Revision 3 Page 489/765
its contents as text, or passed to the Sprite object's
Load image from URL action to display it.
Select
Whether to allow selecting a single file only, or
multiple files in one go.
Initial visibility
Whether the control is initially visible or hidden.
ID
An optional id attribute for the element in the DOM
(Document Object Model). This can be useful for
accessing the element's value from external scripts,
or styling with CSS in the HTML page.
Release file
Release a previously returned file URL. This allows
the browser to release memory for the file. If the user
chooses lots of files or chooses them regularly this
action should be used to release the files after they
are no longer needed.
FileNameAt(index)
Return the name of the chosen file at an index. In
Single select mode, the index should always be 0,
since only one file can be chosen.
FileSizeAt(index)
Return the size of the chosen file in bytes at an
index. In Single select mode, the index should always
be 0, since only one file can be chosen.
FileTypeAt(index)
Revision 3 Page 491/765
Return the MIME type of the chosen file at an index.
The MIME type is the standardised Internet media
type of the file contents. For example, this can be
image/png for a PNG image, image/jpeg for a JPEG
image, or text/plain for a plaintext file. In Single select
mode, the index should always be 0, since only one
file can be chosen.
FileURLAt(index)
The URL to access the local file's contents at an
index. For more information see Using files above. In
Single select mode, the index should always be 0,
since only one file can be chosen.
About functions
The main purpose of the Function object is using the
Call function action. This takes the name of a function
(e.g. Call function "CreateEnemy"). The action then
triggers the corresponding On function event (e.g. On
function "CreateEnemy"), running the event's actions
and any sub-events, before returning to the original Call
function action and continuing from where it was.
Parameters
When calling a function, you can also pass parameters.
These are simply numbers or strings that are made
available to the function. For example, the
CreateEnemy function from the previous example could
be modified to take two parameters: the X and the Y co-
ordinates at which to create the enemy. This helps
functions to be made more general purpose by using
extra information from the action calling the function.
Javascript integration
It is strongly recommended to use the Javascript plugin
SDK to integrate Javascript code with Construct 2.
However it is possible to trigger a function in the
Function object from Javascript code using the following
function:
if (c2_callFunction)
c2_callFunction("name", ["param1", "param2"]);
Function conditions
Compare parameter
Compare the value of one of the parameters to a
function call. This condition should only be used in
an On function event, since outside of function calls
there are no parameters set.
On function
Triggered when the corresponding Call function
action is used.
Function actions
Call expression
This is an alternative to the Call function action. It
simply provides a parameter to enter an expression,
and the result is ignored. You can use this to call a
function via the [Link](...) expression, which
may be more convenient if using a very large number
of parameters.
Call function
Trigger the corresponding On function events.
Additional parameters can be passed that are
accessed by the Param expression.
Function expressions
Call
Call a function directly from an expression. The
expression returns the return value that was set in
the function, or 0 if no return value was set.
Additional parameters can optionally be added after
the name of the function, e.g.
[Link]("CreateEnemy", 123, 456).
Param
Retrieve a parameter passed to a function call by its
zero-based index. For example, [Link](0)
returns the value of the first parameter.
ParamCount
Return the number of parameters passed to a
function call.
ReturnValue
Return the value set using the Set return value
action from the last function call. If Set return value is
not used in a function, it returns 0.
Setting up
To set up your game for Game Center, it must be
appropriately configured on the iTunes store. Please
follow Apple's Game Center configuration guide for
more information.
On auth fail
On auth success
Triggered after the Authenticate action depending on
whether login was successful or not. On auth
success must trigger before any other Game Center
features can be used.
On leaderboard displayed
On leaderboard error
Triggered after the Show leaderboard action
depending on whether the leaderboard could be
successfully displayed or not.
Request achievements
Request a list of available and completed
achievements. Afterwards, On achievement list
error/success triggers depending on success.
Reset achievements
Revision 3 Page 502/765
Reset all the player's achievements and scores to
their default states. Afterwards, On achievement
reset error/success triggers depending on success.
Authenticate
Prompt the player to log in to Game Center, or
automatically log them in again. This must be done
before any Game Center features can be used.
Afterwards, On auth fail/success triggers depending
on success.
Show leaderboard
Display top scores on a leaderboard by its ID. On
leaderboard displayed/error triggers depending on
success.
Submit score
Submit a score to a leaderboard. On score submit
fail/success triggers depending on success.
PlayerID
UserAlias
UserDisplayName
After On auth success, the details about the current
player.
PlayerImageURL
After On player image received, the URL to the
image for the current player. This can be loaded in to
a Sprite object using the Load image from URL
action.
Key mapping
Different controllers have different button layouts, or the
buttons have different names. For example, the
Playstation 3 controller uses square, circle, triangle and
X buttons, whereas the XBox 360 controller uses A, B,
X and Y (note that X appears in a different position in
each controller too). For consistency, the Gamepad
object refers to the XBox 360 layout only.
Multiple gamepads
Multiple gamepad devices can be connected to a single
computer. To differentiate between them, most actions,
conditions and expressions in the Gamepad object also
take a Gamepad parameter. This is a zero-based index
of the controller. For example, 0 identifies the first
controller, 1 identifies the second, and so on. This
allows you to make multiplayer gamepad-controlled
games.
Gamepad properties
Analog deadzone
Gamepad conditions
Gamepads are supported
True if the current platform supports gamepad input.
If this is false, then no gamepads or gamepad
axis/button inputs will be detected at all.
Has gamepads
True if any gamepad is connected and activated. To
prevent websites tracking you based on the available
gamepads, most browsers supporting Gamepad input
will report that no controllers are connected until a
button is pressed on one of the devices.
On gamepad connected
Triggered when a gamepad device is connected to
the computer. To prevent websites tracking you
based on the available gamepads, most browsers
Revision 3 Page 508/765
supporting Gamepad input will report that no
controllers are connected until a button is pressed on
one of the devices, when On gamepad connected
will also run.
On gamepad disconnected
Triggered when a gamepad device is disconnected
from the computer, such as by pulling out its cable.
Compare axis
Compare the position of an analog joystick on a
specific gamepad. Values within the Analog
deadzone are returned as 0. Axes values range from
-100 to 100.
Is button down
True if a given button is currently down on a specific
gamepad. The buttons are always referred to
according to the XBox 360 controller layout, and
buttons are subject to mapping as described under
Key mapping.
On button pressed
Triggered when a given button is pressed on a
specific gamepad. The buttons are always referred to
according to the XBox 360 controller layout, and
buttons are subject to mapping as described under
Key mapping.
On button released
Triggered when a given button is released on a
specific gamepad. The buttons are always referred to
according to the XBox 360 controller layout, and
buttons are subject to mapping as described under
Key mapping.
Gamepad expressions
Axis(Gamepad, Index)
Retrieve the current position of an analog joystick on
a specific gamepad. Index specifies left analog X and
Y or right analog X and Y axes, subject to Key
mapping. Axes range from -100 to 100. Axis values
within the Analog deadzone are returned as 0.
Button(Gamepad, Index)
Retrieve the current button press value of a button on
a specific gamepad. Index specifies the zero-based
index of a button from the dropdown list in the Is
button down condition (e.g. 0 returns the value for
the A button). The returned value depends on the
features of the button: if the button is pressure
sensitive, it can return any value from 0 to 100
depending on the pressure; otherwise it returns 0 for
not pressed and 100 for pressed. Buttons which are
not pressure sensitive are easier to detect using the
Is button down condition.
GamepadCount
Return the number of currently connected and active
gamepad devices. To prevent websites tracking you
based on the available gamepads, most browsers
supporting Gamepad input will report that no
Revision 3 Page 511/765
controllers are connected until a button is pressed on
one of the devices.
GamepadID(Gamepad)
A string intended to represent the device
manufacturer and model for a specific gamepad, e.g.
"XBox 360 controller". However in practice this varies
depending on the system and browser in use.
LastButton(Gamepad)
Return the numerical index of the last button pressed
on a specific gamepad. This is useful with the On any
button pressed and On any button released triggers
to set up custom controls.
RawAxis(Gamepad, Index)
Retrieve raw axis input for a specific gamepad and
axis index. This returns the value without
keymapping, applying the analog deadzone, or
multiplying the returned value by 100. Axis values
range from -1 to 1.
RawAxisCount(Gamepad)
Return the number of axes available in the raw input
for a specific gamepad. This returns the value without
keymapping.
RawButton(Gamepad, Index)
Retrieve raw button input for a specific gamepad and
button index. This returns the value without
keymapping. Button values range from 0 to 1
Revision 3 Page 512/765
(pressure sensitive buttons can return values in
between).
RawButtonCount(Gamepad)
Return the number of buttons available in the raw
input for a specific gamepad. This returns the value
without keymapping.
Permission prompts
When requesting the user's location, for privacy
reasons most platforms will prompt the user for
permission. Each platform tends to have its own specific
way of asking for permission. The user may decline the
permission request, in which case On error will trigger.
Revision 3 Page 514/765
Your projects should handle such a case gracefully if
possible. Normally each browser or platform has a way
to grant permission when it was previously declined, but
it either involves prompting again, or making changes in
the browser or app platform settings. Some platforms
will fail without even prompting the user after a single
declined permission request.
Battery usage
It should be noted that tracking the user's location may
involve activating GPS hardware in a phone or tablet,
which can drain the battery more quickly. Requesting
high-accuracy location information is also likely to use
more power. Try to only request the user's location if
absolutely necessary, use low accuracy if suitable, and
request one-off positions rather than watching the
position for a long time.
Geolocation conditions
Is supported
True if the current device supports reporting the user
position with geolocation. If false, none of the
features of the object will work.
Is watching location
True after a successful Watch location action, until
the Stop watching action is used.
On error
Revision 3 Page 515/765
Triggered if an error occurs when requesting
permission for, or retrieving, the user's location. The
ErrorMessage expression contains more information
about the problem in this trigger.
On location update
Triggered after a successful Request location or
Watch location action, when the position has been
updated. This only triggers once after a successful
Request location action, but can trigger regularly
after a successful Watch location action whilst the
position is tracked and updated.
Geolocation actions
Request location
Make a one-off request for the user's current
location. The user may see a permission prompt
which they must approve before any information is
returned; if they decline, On error will trigger.
Accuracy can be set to High to get more accurate
results, but it may take longer to calculate and
consume more battery. Timeout is the maximum time
in seconds the device may take before it must return
a position or trigger On error. Maximum age is the
maximum age of a cached result that can be
returned. If zero, the device will actively try to
determine the user's position at that time. However if
it is nonzero, and the operating system had
previously requested the user's position within that
Revision 3 Page 516/765
time, the previous result may be returned immediately
instead. This is faster and can save battery, but the
result will not be as close to real-time. If a result is
successfully determined, On location update will
trigger.
Watch location
As with Request location, but the location will be
tracked. On location update will trigger whenever
new position information is available, until the Stop
watching action is used. Watching the location can
consume more battery on mobile devices than one-
off requests.
Stop watching
Stop a previous successful request to watch the
user's location. The position will no longer be
updated.
Geolocation expressions
The position-related expressions only update when On
location update triggers, which in turn can only occur
after a successful Request location or Watch location
action.
Accuracy
AltitudeAccuracy
The estimated accuracy in meters of the latitude and
longitude (for Accuracy) or the altitude (for
AltitudeAccuracy). The accuracy may be more or
Revision 3 Page 517/765
less a guess, or if it is not known the expression
returns 0.
Altitude
The estimated altitude in meters relative to sea-level,
or 0 if not known.
ErrorMessage
In On error, a string with some additional information
about the error.
Heading
Speed
While watching a position, the direction of travel in
degrees relative to due north and speed in meters per
second if available, else 0 of not available.
Latitude
Longitude
The latitude and longitude that has been determined,
subject to the Accuracy (which may not be known).
Timestamp
A timestamp of the time at which the current details
were retrieved. This is measured in milliseconds
since midnight, January 1, 1970.
For each game that you wish to use Google Play Game
Services for, click the Game Services icon in the
developer console and then click Add a new game.
Enter the name of your game, choose its category, and
click Continue.
Once added you can edit the game details such as its
description and any associated images. You can also
add achievements and leaderboards - which must be
added before you can use them in the Google Play
plugin - as well as configure testing and publishing.
[Link]
.[Link]
1 Fill in the Client secret property with the value from the
Google Play Developer Console.
2 Add [Link] as one of the redirect URIs in the
API console.
3 Remove any uses of On auto-sign in failed. It never
triggers in this mode, so you will need to rely on having
Revision 3 Page 520/765
manual sign-in instead.
[Link]
[Link]
[Link]
Basic usage
To use the Google Play plugin, you must first wait for it
to finish loading. Do not attempt to use any features of
the plugin until On loaded triggers, or Is loaded is true.
Once the user is signed in, you can make use of the
other plugin features such as requesting leaderboards,
submitting high-scores, and unlocking achievements.
Asynchronous actions
Most actions in the Google Play plugin are
asynchronous. This means they are not completed
immediately. Instead, the action starts a request which
is sent off to the Google Play servers. A few moments
later the server will respond, and a corresponding trigger
will run in the Google Play plugin.
Client ID
The client ID for the game from the Google Play
Developer Console. For more information see the
section Setting up Google Play Game Services
above.
Client secret
The client secret for the game from the Google Play
Developer Console. This is only necessary when
publishing via Cordova (e.g. PhoneGap Build). For
more information see the section Setting up Google
Play Game Services above.
On achievement revealed
On achievement unlocked
Triggered after the Reveal, Unlock or Increment
actions when an achievement has successfully been
revealed or unlocked. When incrementing
achievements, the achievement is unlocked when it
has incremented through every step.
Is loaded
True if the Google Play plugin has loaded and is
ready to use. Before this is true, no features of the
plugin will work.
Is signed in
True if the user has been successfully signed in
(possibly automatically).
Revision 3 Page 524/765
On auto-sign in failed
Triggered upon the first visit, when the user cannot
be automatically logged in. It is necessary to display a
'Sign in' button and use the Sign in action to get the
user to sign in.
On error
Triggered if an error occurs. The ErrorMessage
expression will contain information about the error.
On loaded
Triggered when the plugin finishes loading and is
ready to use. Before this triggers, no features of the
plugin will work.
On signed in
On signed out
Triggers when the user is signed in or signed out
from Google Play Game Services.
Increment
Set steps
Add to, or set, the number of steps in an incremental
achievement. Once the full number of steps has
been reached, the achievement is automatically
unlocked.
List achievements
List the achievements for the currently signed in
player. Optionally the list of achievements can be
filtered to only those in a given state (e.g. revealed). If
successful, On achievement list success triggers.
Revision 3 Page 526/765
Reveal
If an achievement is hidden, set its state to 'revealed'
for the currently signed in player. If revealing for the
first time, On achievement revealed will be triggered.
Unlock
If an achievement is not already unlocked, set its
state to unlocked for the currently signed in player. If
unlocking for the first time, On achievement
unlocked will be triggered.
Sign in
If the player is not already signed in, pop up a window
that allows them to sign in. Due to popup blockers,
this may only work in a user input event, such as On
button clicked or On touch start.
Sign out
If the player is already signed in, sign them out. This
also allows for a different user to then sign in.
Request hi-scores
Request a hi-score list for a given leaderboard.
Scores can be returned for public results, or "social"
Revision 3 Page 527/765
(from users connected to the currently signed in
player), and a time limit can be applied such as to
return only the day's best scores so far. The top type
returns the very highest scores, and the window type
returns the scores around the current player's own
best score, allowing them to see where they appear in
the rankings.
Submit score
Submit a new hi-score to a leaderboard. A tag can be
provided, which is just a short string (up to 64
characters) associated with this score board entry,
e.g. a short comment or an alternative alias for the
player. If successfully submitted, On score submit
success triggers.
AchievementNameAt(index)
AchievementDescriptionAt(index)
AchievementIDAt(index)
AchievementStepsAt(index)
AchievementTotalStepsAt(index)
AchievementTypeAt(index)
Retrieve information about a given achievement in
the achievements list. The achievements list must
Revision 3 Page 528/765
already have been successfully requested.
AchievementUnlockedIconURLAt(index)
AchievementRevealedIconURLAt(index)
Retrieve the icon image URL for a given icon in either
its unlocked or revealed state. This can be displayed
using the Sprite object's Load image from URL
action.
ErrorMessage
In On error, the relevant error message if available.
HiScoreCount
The number of hi-scores in the current returned list of
results.
HiScoreTotalCount
The total number of scores in the leaderboard, which
may be greater than the number of returned results
(HiScoreCount).
HiScoreAt(index)
HiScoreFormattedAt(index)
Return a numerical value, or formatted string, for a
score at a given index.
HiScoreRankAt(index)
HiScoreFormattedRankAt(index)
Return the numerical rank, or formatted string of the
rank (e.g. "1st"), at a given index.
Revision 3 Page 529/765
HiScoreNameAt(index)
Return the name of the player associated with the
score at an index.
HiScoreTagAt(index)
Return the tag (a short string) that was submitted
along with the score at an index.
HiScoreMyBest
HiScoreMyFormattedBest
HiScoreMyBestRank
HiScoreMyBestFormattedRank
HiScoreMyBestTag
Return the details for the current player's own best
score, including the numerical and formatted versions
of the score and rank.
Setup
For information on how to register for an iAd account
and set up your app to use it, please refer to Apple's
documentation, in particular the iTunes Connect
developer guide.
iAd properties
The iAd object has no properties.
iAd conditions
On banner received
Triggered after the Load banner action, when the
banner has been downloaded and is ready to be
Revision 3 Page 531/765
displayed.
On banner error
Triggered if an error occurs trying to display a banner
ad at any time.
iAd actions
Load banner
Start loading a banner at a given position on the
screen. If Auto-show is Yes, as soon as the banner
is loaded it will be displayed. If No, it will trigger On
banner received but not display it. The banner can
then be shown any time after that trigger instantly,
providing a way to pre-load banners.
Show/hide banner
Display a pre-loaded banner, or hide any showing
banner.
iAd expressions
The iAd object has no expressions.
Supported stores
Currently the IAP plugin supports these platforms:
Platform documentation
Each operating system has a different way of
configuring in-app purchases. Please refer to vendor
Revision 3 Page 533/765
documentation for further help. Links are provided
below.
Basic usage
To access in-app purchasing features, the basic usage
is as follows:
Terminology
The plugin uses a Product ID to refer to an individual
item available for sale. This is a short unique string, e.g.
"myitem". Some stores instead refer to this in different
ways, such as the "SKU". This does not matter; you can
still enter it as a product ID, so long as it is the string
that identifies the item. This is usually also different to
the product name.
App purchases
The Windows Store allows the app itself to be
purchased, e.g. to unlock premium features. The IAP
has features such as the Purchase app action to
support this. However the other platforms do not support
the app itself being purchased. To make sure your
events are compatible with other stores, purchasing the
app will translate in to purchasing a product with the ID
"app".
Publishing
When publishing your app, it will be necessary to set up
the store with the list of items you wish to have available
for sale. The process for this is different for each
platform and is usually part of the publishing process.
Be sure to carefully record any product IDs you use in
your events, and make sure you add an item with each
product ID when publishing. Note that as described in
the App purchases section above, if you use app
purchases you should add a product with the ID "app" to
represent purchasing the app itself on all stores except
the Windows Store.
IAP properties
Test mode
See the section on Using Test Mode above.
Item group ID
(under Tizen store settings) This setting applies only
Revision 3 Page 536/765
to apps published to the Tizen store. When
publishing your app, create an item group for the IAP
items you want available in the app, and then enter
the item group ID in to this property.
IAP conditions
Has product
Test if a given product ID has been successfully
purchased by the user. Note that in some cases this
will be false for the first few seconds of the app
running even if the user has purchased the item, and
then later become true when the store finishes
loading the store status in the background. Try to
avoid using this condition before On store listing
success triggers.
Is app purchased
On the Windows Store, test if the app itself has been
purchased. On other platforms, tests if the product ID
"app" has been purchased.
Is store available
True if a supported store is currently available and
purchases can be made. False on unsupported
platforms or if no store is available (such as in an
ordinary web browser).
On purchase success
On purchase failed
Triggered after the purchase of a specific product ID
finishes, to indicate whether it was successful (and
the item is now owned) or unsuccessful.
IAP actions
Add product ID
Use on start of layout to indicate all the product IDs
the app will be using. The action can be used multiple
times, or with a comma-separated list of product IDs
to add multiple products at once. See the section on
Basic usage above for more information.
Purchase app
On the Windows Store, request to purchase the app
itself. On other platforms, request the purchase of the
product ID "app".
Revision 3 Page 538/765
Purchase product
Request to purchase a particular product by its
product ID.
Restore purchases
Update the status of which items have been
purchased from the store.
IAP expressions
AppName
AppPrice
Return the name and price of the app itself on the
Windows Store. On other platforms, returns the
name and price of the product ID "app".
Error message
In a "failed" trigger, the error message text if
available.
ProductID
The ID of the relevant product in a trigger, e.g. On
any purchase success.
Caching enabled
(For advanced users) True if Intel AGI's caching
service has been enabled.
Compare orientation
Test if the current orientation of the device is a
particular orientation.
Push enabled
Revision 3 Page 541/765
(For advanced users) True if Intel AGI's push
notifications service is enabled.
Streaming enabled
(For advanced users) True if Intel AGI's streaming
service is enabled.
Updates enabled
True if Intel AGI's cloud update service is enabled.
On barcode scanned
Triggered when the device successfully scans a
barcode.
On remote data
Triggered when data is received from the Get remote
data action.
Remove cookie
Remove a cookie set with the Set cookie action. (The
user's browser cookies are not affected.)
Set cookie
Set a cookie on the device. This is a substitute for
Revision 3 Page 543/765
local storage. The user's browser is not affected;
storage is for the convenience of the app only.
Install update
Install a pending update if one is ready.
Scan barcode
Open a fullscreen QR code reader. On barcode
scanned will trigger on a successful scan.
Set auto-rotate
Prevent the device from automatically rotating the
display when the device changes orientation. This
can force a specific orientation when used with Set
orientation.
Update connection
Check whether the device's connection type has
changed (e.g. 3G, Wifi, etc).
LocalMediaCacheURL
Get the local path for a media file cached from the
Internet via the Add to media cache action.
DeviceBarcodeData
Return the data scanned from a barcode. This is only
available in On barcode scanned after calling the
Scan barcode action.
DeviceConnection
The type of the best connection available to the
device: either "wifi", "cell" or "none".
DeviceModel
The model name of the device.
DeviceOSVersion
The OS version information for the device.
DevicePlatform
"iOS" or "Android" depending on the current platform.
DeviceQueryString
Returns any query string passed along to the
application when launched with a protocol handler.
DeviceRemoteData
The data returned from Get remote data after On
remote data triggers.
Revision 3 Page 546/765
DeviceRemoteStatus
One of "open", "closed" or "idle".
DeviceUUID
Return the device's Universally Unique Identifier
(UUID), which is a code uniquely identifying the
specific device.
InitialOrientation
The device orientation upon startup, as a number of
degrees (0, -90, 90 or 180).
Orientation
The current device orientation, as a number of
degrees (0, -90, 90 or 180).
Key codes
It's possible to detect key presses by numerical key
codes with the Keyboard object. A key code is simply a
number assigned to every possible key on the
keyboard. This can be useful for implementing custom
controls, since key codes can be stored in variables.
Keyboard conditions
Key code is down
True if a given key by its key code is currently being
held down.
Key is down
True if a given keyboard key is currently being held
Revision 3 Page 549/765
down.
On key pressed
Triggered when a specific keyboard key is pressed.
On key released
Triggered when a specific keyboard key is released.
Keyboard actions
The Keyboard object does not have any actions.
Keyboard expressions
LastKeyCode
Retrieve the key code of the last key press. This is
useful in On any key pressed or On any key
released to determine the key code of the key the
user pressed, which is useful when setting up custom
controls.
Revision 3 Page 550/765
StringFromKeyCode
Convert a numerical key code back in to a string
representation. For example this turns the key code
65 in to the string "A".
List properties
Items
A semicolon-separated list of the initial items to
display in the list. For example, One;Two;Three will
display three separate choices.
Tooltip
A tooltip that appears in most browsers if the user
hovers the mouse over the button and waits. Leave
blank for no tooltip.
Enabled
Whether the control is initially enabled. If No, the
control will appear greyed out and the selection
cannot be modified.
Type
Choose between the List box and Dropdown list
control styles. An image displaying the two types is
shown above.
Multi-select
Allow more than one item to be selected when Type
is List box. This has no effect for dropdown lists.
ID (optional)
An optional id attribute for the element in the DOM
(Document Object Model). This can be useful for
accessing the element's value from external scripts,
Revision 3 Page 554/765
or styling with CSS in the HTML page.
List conditions
Compare item text at
Compare the text of a given item in the list.
Compare selection
Compare the zero-based index of the currently
selected item.
On clicked
Triggered when the control is clicked.
On double-clicked
Triggered when the control is double-clicked.
On selection changed
Triggered whenever the chosen selection in the
control is changed. This can be by any means of
input (such as a mouse click, keyboard press, or
touch input on mobile).
List actions
Set CSS style
Revision 3 Page 555/765
Set a CSS (Cascading Style Sheets) style on the list
element. For more information, see the section
Styling List objects. Note that if the Auto font size
property is set to Yes, any changes to the font-size
property will be overridden.
Add item
Append a new item to the end of the list of available
choices.
Add item at
Insert a new item to the list of available choices at a
certain zero-based index.
Clear
Remove all the available choices from the list.
Remove
Delete an item at a specific index.
Set selection
Set the item at a specific index as selected.
Set enabled
Enable or disable the control. If disabled, it will appear
greyed out and the selection cannot be modified.
Set focused
Set unfocused
Either set or unset the input focus to this control.
When focused, keyboard input affects the control.
List expressions
ItemCount
The current number of items in the list.
ItemTextAt
Return the text of an item at a zero-based index in the
list.
SelectedCount
The number of currently selected items. This will
always be either 0 or 1 unless a list box with Multi-
select enabled is used.
SelectedIndex
The zero-based index of the currently selected item.
For multi-select lists, use SelectedIndexAt instead.
SelectedIndexAt
The index of a selected item out of all the selected
Revision 3 Page 557/765
items. In other words, SelectedIndexAt with numbers
0 to SelectedCount - 1 gives the indices of all the
selected items.
SelectedText
The text of the currently selected item. For multi-
select lists, use SelectedTextAt instead.
SelectedTextAt
The text of a selected item out of all the selected
items. In other words, SelectedTextAt with numbers
0 to SelectedCount - 1 gives the text of each
selected item.
Storage quotas
Revision 3 Page 559/765
To prevent abuse, most browsers implement a storage
quota, which is a maximum amount of data that can be
saved locally. On most modern browsers this is at least
50mb. If the quota is exceeded, the On error trigger will
fire.
On item exists
Triggered after the Check item exists action
completes if the key checked does indeed exist. In
this trigger the ItemValue expression is also set to the
value of this key, so there is no need to use another
Get item action to read it.
On item get
Triggered after a Get item action completes for a
given key. The ItemValue expression is set to the
value of the key.
Revision 3 Page 562/765
On item missing
Triggered after the Check item exists action
completes if the key checked does not exist.
On item removed
Triggered after the Remove item action completes for
a given key.
On item set
Triggered after the Set item action completes for a
given key. This indicates the data is now in storage.
Compare key
Compare the current value of the Key expression,
which is the name of the current key in a trigger. This
can be useful in the On any item... triggers.
Compare value
Compare the current value of the ItemValue
expression, which is set to the item value when
getting an item or in On item exists.
On error
Triggered at any time while using Local Storage if an
error occurs, such as if a write failed, or the maximum
Revision 3 Page 563/765
storage quota was exceeded. The ErrorMessage
expression is set to the error message if available.
On storage cleared
Triggered after the Clear storage action completes
and storage is now empty.
Is processing gets
True if any Get item actions are still processing, i.e.
any On item get trigger is yet to fire for a Get item
action.
Is processing sets
True if any Set item actions are still processing, i.e.
any On item set trigger is yet to fire for a Set item
action.
Get item
Read the value of a key in storage. This triggers On
item get when the value has been read, where the
ItemValue expression is set to the value of the key.
Remove item
Remove (delete) a key from storage. This triggers On
item removed when the key has been removed.
Set item
Set the value of a key in storage. This triggers On
item set when the value has been written.
Clear storage
Remove (delete) all items from storage, reverting it
back to the empty state. This triggers On storage
cleared when completed.
Revision 3 Page 565/765
Get all key names
Retrieve a list of all the key names that currently exist
in storage. This triggers On all key names loaded
when the list has been loaded, where the KeyCount
and KeyAt expressions can be used to access the
list.
Key
The name of the key that was modified in any Local
Storage trigger, such as On item get, On item set or
On any item set. This returns an empty string if used
outside of a Local Storage trigger.
ErrorMessage
In On error, the text of the error message if any is
available.
KeyAt(index)
In On all key names loaded, the name of the key at
the given zero-based index in the list.
Mouse conditions
Cursor is over object
True if the mouse cursor is hovering over an object.
On any click
Triggered when any mouse button is clicked. Useful
for title screens or cutscenes.
On button released
Triggered when a given mouse button is released.
On click
Triggered when a given mouse button is pressed.
This can also be used to detect double-clicks.
On mouse wheel
Triggered when the mouse wheel (if any) is scrolled
up or down a notch. Note: adding this trigger
Revision 3 Page 569/765
anywhere in your game will prevent the mouse wheel
scrolling the page in the browser, so use this with
care.
On object clicked
Triggered when a given mouse button is pressed
while the mouse cursor is over an object. This can
also be used to detect double-clicks on objects.
Mouse actions
Set cursor from sprite
Set the cursor image from a Sprite object. This is
preferable to setting a sprite to the mouse co-
ordinates, because the input lag is significantly lower.
Various limitations apply: the sprite image is used as
it appears in the image editor, not taking in to account
size or rotation in the layout; the image cannot be too
large (64x64 is usually the limit); and support varies
depending on browser and OS.
Mouse expressions
AbsoluteX
AbsoluteY
Return the position of the mouse cursor over the
Revision 3 Page 570/765
canvas area in the HTML page. This is (0, 0) at the
top left of the canvas and goes up to the window size.
It is not affected by any scrolling or scaling in the
game.
X
Y
Return the position of the mouse cursor in game co-
ordinates. This is (0, 0) at the top left of the layout. It
changes to reflect scrolling and scaling. However, if
an individual layer has been scrolled, scaled or
rotated, these expressions do not take that in to
account - for that case, use the layer versions below.
X("layer")
Y("layer")
Return the position of the mouse cursor in game co-
ordinates, with scrolling, scaling and rotation taken in
to account for the given layer. The layer can be
identified either by a string of its name or its zero-
based index (e.g. Mouse.X(0)).
Multiplayer features
The Multiplayer object supports a number of features to
enable low-latency gameplay over the Internet:
Peer IDs
The signalling server assigns every player who
connects a Peer ID. This is a short string of random
characters that uniquely identifies them, such as
"ABCD". When designing multiplayer games, it is best
to identify peers by their peer ID instead of their alias
(display name), since their alias could potentially change
but their peer ID never changes so long as they remain
connected.
Sending messages
Peers only connect to the host. In other words, the host
has a connection to every peer, and peers only have
one connection to the host. In order for two peers to
communicate, the information must be relayed via the
host.
Updating games
The host is authoritative for both gameplay data and its
settings. If you change any aspect of your game, such
as the synced objects or variables, the client input
values, or bandwidth profile, the host's values are
authoritative when there is a mismatch between the peer
and the host. In order to avoid confusion or broken
games, use a different game instance name when
distributing an update, so only peers using the same
version end up connecting to each other.
Multiplayer conditions
Compare peer count
Compare the number of peers currently in the room,
if a room has been joined. The peer count includes
the host so is at least 1 if in a room.
Is host
True if in a room and acting as the host. The host of
the room is effectively the server for the game. Peers
only connect to the host, and the host must relay
data if two other peers are to communicate.
Revision 3 Page 577/765
On any peer message
Triggered when a message with any tag is received.
The Message, Tag, FromID and FromAlias
expressions can be used to retrieve information about
the received message. The order messages are
received, or whether a sent message is received at
all, depends on the reliability mode chosen when the
message was originally sent.
On kicked
Triggered if kicked from the current room. This can
occur if the host quits, the connection to the host
could not be established, or the host otherwise
decides to forcibly remove you from the room. After
On kicked the player is no longer in the room and
must re-join a room to be able to participate in a
game.
On peer connected
Triggered when another peer joins the same room. It
also triggers once per peer already in the room when
joining an existing room, including the host. The
PeerID and PeerAlias expressions identify the
relevant peer.
On peer disconnected
Triggered when a peer disconnects from the room.
The PeerID and PeerAlias expressions identify the
peer that left. The LeaveReason expression can
indicate why the peer left, such as if they intentionally
Revision 3 Page 578/765
quit or timed out.
On peer message
Triggered when a message sent with a specific tag is
received. The Message, FromID and FromAlias
expressions can be used to retrieve information about
the received message. The order messages are
received, or whether a sent message is received at
all, depends on the reliability mode chosen when the
message was originally sent.
On client update
Triggered when a peer is about to send its input state
to the host. The input state should be updated in this
trigger using the Set client state action.
Is connected
True if currently connected to the signalling server. It
is not necessary to be connected to a signalling
server once connected to the room host.
Is in room
Revision 3 Page 579/765
True if currently in a room on the signalling server.
Is logged in
True if currently connected to the signalling server
and successfully logged in.
On connected
Triggered after successfully connecting to the
signalling server. In order to join rooms, it is
necessary to next log in to the server.
On disconnected
Triggered after disconnecting from the signalling
server.
On error
Triggered if an error occurs with the signalling server.
The ErrorMessage expression indicates the type of
error that occurred.
On joined room
Triggered after the Join room or Auto-join room
actions when the room has been successfully joined.
The Is host condition can be used to determine if the
Revision 3 Page 580/765
player is the first joining peer and has been assigned
the room host.
On left room
Triggered after the Leave room action when the room
has been left. The room is also left if On kicked
triggers.
On logged in
Triggered after the Log in action if the login is
successful. Once logged in it is possible to join
rooms. Note the signalling server may have assigned
a different alias to the one requested if it was already
taken; use the MyAlias expression to determine the
actual alias in use.
On room list
Triggered after the Request room list action when the
room list has been successfully received. The room
list expressions can then be used to inspect the
received list.
Supports multiplayer
Test if the current browser or platform supports
multiplayer games. If false, none of the features of
the Multiplayer object will work.
Multiplayer actions
Add client input value
Use on startup to add a value that peers send to the
Revision 3 Page 581/765
host to indicate their input state. Each client input
value has a tag to identify it; use this tag to update
the value with the Set client state action. To avoid
wasting bandwidth, use the lowest Precision that can
still hold all the values that need to be set. If using
setbit / getbit to send key states, you must use None
for Interpolation; otherwise use Linear for values like
positions, or Angular if representing an angle.
Disconnect
Disconnect from the room. If the room host, all
players are kicked; otherwise the peer disconnects
from the host. The room is also left on the signalling
server, so another room can be joined afterwards.
Send message
Send a message to a specific peer with a given
reliability mode. Peers can only message the host
(and the Peer ID field must be left empty), but the
host can send a message to any peer. Message tags
can be used to identify messages for different
purposes, such as "chat" or "gameplay-event". The
Revision 3 Page 582/765
message must be a text string, but could also be
JSON data such as from an Array or Dictionary
AsJSON expression; however be sure to avoid
wasting bandwidth. The order messages arrive, or
whether it is guaranteed to arrive at all, depends on
the reliability mode.
Simulate latency
Simulate latency, PDV and packet loss on all
inbound and outbound messages. This can be useful
for making local testing more realistic, since unlike
the Internet latency is effectively non-existent. For
Revision 3 Page 583/765
local testing it is only necessary to simulate latency
on the host, since that guarantees every message in
the game will have delay added; it is not necessary to
also simulate latency on the peers. The latency for an
individual message is calculated as the latency plus a
random value from zero to the PDV. The packet loss
indicates the chance an unreliable message is lost
entirely, or in the case of reliable messages that
retransmission is necessary and the latency is
multiplied.
Sync object
Automatically sync an object. The host sends
information about synced objects to peers. This is
one-way transmission; peers sync with what is
happening on the host. As synced objects are
created, moved and destroyed on the host, they are
correspondingly created, moved and destroyed on all
connected peers. It is important to disable any
behaviors and deactivate any events on the peers
that may attempt to move the objects themselves; this
will conflict with what Sync object is trying to do, and
will not have any effect on the host. Peers should use
their client input values as their sole way of
influencing the game. Synced objects can optionally
include their position and/or angle with a given
precision; if None, then it simply ensures the same
numbers of objects are created. Bandwidth can be
used to reduce the number of updates it is necessary
to send for a synced objects. Normal bandwidth
(unpredictable) will send updates for the object at
Revision 3 Page 584/765
most every update (30 times a second in Internet
mode) and is suitable for objects with unpredictable
movement. Low bandwidth (highly predictable) will
send updates at most 10 times a second, which
should only be used for highly predictable motion
such as moving in a straight line at the same speed
(it is not enough to handle changes in motion
smoothly). Very low bandwidth (essentially static)
will send updates at most twice a second, which
should only be used for objects which are not
expected to move but nevertheless can occasionally
be created or destroyed, such as scenery. Note that
even in Normal bandwidth mode, objects which are
not changing gradually reduce their bandwidth to
twice a second anyway, so static objects will still end
up using Very low bandwidth mode. Therefore it is
not normally necessary to change this, and it is
suitable to use Normal bandwidth even for objects
which rarely change.
Broadcast message
As with Send message, but can only be used by the
host. This sends a message to every peer in the
room. From ID can be used to indicate the message
is being sent on behalf of another peer; if it is used,
when peers receive the message the FromID and
FromAlias will be set to this peer. Also the message
will not be sent to the specified From ID peer, since
usually this is redundant. If it is empty, it will be sent
to all peers and received as from the host.
Kick peer
When host, forcibly disconnect a peer from the room
so they are no longer participating. The kicked peer
will be notified that they have been disconnected and
optionally the kick reason can be displayed. Peers
cannot kick anyone, only the host can.
Auto-join room
Join the first available room with the given game,
instance and first room name. The player must be
connected and logged in to the signalling server. The
first player to join a room becomes the host. Be sure
to use a unique name for the Game. For example if
"myroom" is full, it will try "myroom2", "myroom3", etc.
This effectively arranges all joining peers in to games
Revision 3 Page 587/765
of a particular size. If the room is locked when full,
then late-joiners are not allowed; if left unlocked and
a peer leaves after the game starts, a newly joining
peer may be added back to the game to top it up to
the Max peers again. Upon joining, On joined room
triggers.
Connect
Connect to a signalling server. The official Scirra
signalling server is at [Link] .
Upon successful connection, On connected will
trigger.
Disconnect
Disconnect from the signalling server.
Join room
Join a specific room in the given game instance. The
player must be connected and logged in to the
signalling server. The first player to join a room
becomes the host. Max peers can be used to limit the
number of peers that join. Only the host's value is
used. If the room is full, subsequently joining peers
will receive a "room full" error. The peer count
includes the host, so 2 is the minimum value, or it
can be left as 0 to allow an unlimited number of peers
to join. Upon successfully joining, On joined room
triggers.
Leave room
If in a room, leaves the room on the signalling server.
Revision 3 Page 588/765
On left room triggers upon the server acknowledging
the request to leave. Note the room has not really
been left until that trigger runs.
Log in
Once connected, log in to the signalling server.
Players must log in before they can join rooms. The
Alias is the requested display name to use. Note that
if the requested alias is already taken, the server will
automatically assign an alternative; be sure to use
the [Link] after logging in to determine
the actual alias in use. Upon a successful login, On
logged in triggers.
Multiplayer expressions
ListInstanceCount
Revision 3 Page 589/765
After On game instance list triggers, the number of
game instances in the received list.
ListInstanceName(index)
ListInstancePeerCount(index)
Get the name and peer count of a given game
instance in the returned instance list.
ListRoomCount
After On room list, the number of rooms in the
received list.
ListRoomName(index)
ListRoomPeerCount(index)
ListRoomMaxPeerCount(index)
ListRoomState(index)
After On room list, retrieve information for a room at
an index in the received list. The state can be one of
"available", "locked" or "full".
FromAlias
FromID
The alias and ID of the peer a message is from in On
message received or On any message received.
HostAlias
HostID
When in a room, the alias and ID of the host of the
room.
LeaveReason
Revision 3 Page 590/765
A string identifying a reason for leaving in On peer
disconnected, if known, e.g. "quit", "timeout",
"network error"...
Message
The contents of the received message in On
message received or On any message received.
PeerAlias
PeerID
The alias and ID of the relevant peer in a trigger like
On peer connected or On peer disconnected.
PeerCount
The number of peers in the current room, including
the host.
PeerAliasAt(index)
PeerIDAt(index)
The alias and ID of the nth peer in the current room,
up to PeerCount.
PeerAliasFromID(peerid)
Get the alias of a peer in the current room from their
peer ID.
PeerLatency(peerid)
PeerPDV(peerid)
Get the latency and packet delay variation (PDV) of a
peer from their peer ID. Peers can only use this to get
Revision 3 Page 591/765
the stats for the host, since that is the only
connection they have, but the host can use it for any
peer.
Tag
The tag of the received message in On any message
received.
LagCompensateAngle(movingPeerID, fromPeerID)
LagCompensateX(movingPeerID, fromPeerID)
LagCompensateY(movingPeerID, fromPeerID)
Return the lag-compensated position and angle for
movingPeerID as seen by fromPeerID. In other
words, this returns the past position of movingPeerID
going back by the amount of time that fromPeerID is
delayed by, given their latency. For example this can
be used to perform a lag-compensated hit-test when
fromPeerID shoots a laser. This is covered in more
detail in the fourth multiplayer tutorial.
PeerState(peerid, tag)
When host, retrieve the latest client state value with
the given tag, for a given peer ID. The peer will have
set this with the Set client state action to indicate
their input state.
CurrentGame
CurrentInstance
CurrentRoom
Retrieve the current game, instance and room
names, if joined on the signalling server.
Revision 3 Page 592/765
ErrorMessage
In On signalling error, the error message if available.
MyAlias
MyID
The current player's own alias and ID, once
connected and logged in to the signalling server.
SignallingMOTD
SignallingName
SignallingOperator
SignallingURL
SignallingVersion
Once connected to the signalling server, retrieve the
Message Of The Day (MOTD), server name, server
operator, website URL and server version for the
connected server.
ClientXError
ClientYError
The input prediction error for peers, used for
debugging.
HostX
HostY
The position the host has for the current peer, used
for debugging.
StatInboundBandwidth
StatOutboundBandwidth
Revision 3 Page 593/765
Return the total estimated inbound and outbound
bandwidth for all data transmission through the
Multiplayer object, in bytes per second.
StatInboundCount
StatOutboundCount
Return the total number of separate inbound and
outbound messages sent and received by the
Multiplayer object. This includes internally-used
messages for things like ping and synchronisation;
generally the bandwidth is the more practically useful
statistic.
Note that the AJAX object can read files from the
application folder (but not write files) when exporting to
[Link]. This may allow you to implement file reading in a
cross-platform manner. Also note the AJAX object
reads files asynchronously, whereas the [Link] object
conducts all operations synchronously.
What is [Link]?
[Link] is essentially a standalone version of the Google
Chrome web browser, but while looking like an ordinary
desktop app (so there are no browser tabs, address bar,
back/forward buttons etc). Exporting using [Link] allows
your project to run as a standalone desktop app on
Windows, Mac and Linux, and does not require any
particular other browser to be installed.
Previewing
Since [Link] is based on the Google Chrome browser,
Revision 3 Page 595/765
usually previewing in Chrome will run it identically to
when exported with [Link]. However the features of the
[Link] plugin (such as file access) do not work in the
Google Chrome web browser. In order to test these
features in preview mode, it is possible to choose [Link]
for the Preview browser project property. This allows
you to test your game with the features of this plugin
working.
[Link] conditions
On folder dialog OK
On folder dialog cancel
Triggered after the Show folder dialog action,
depending on if the user selected OK or Cancel. The
ChosenPath expression contains the selected folder
after an OK.
On save dialog OK
On save dialog cancel
Triggered after the Show save dialog action,
depending on if the user selected OK or Cancel. The
ChosenPath expression contains the selected file to
save after an OK.
On file dropped
Triggered after the user drag-and-drops a file in to the
application window. The DroppedFile expression
contains the path to the file that was dropped in,
allowing you to load it to read its contents.
Path exists
Test if a given folder or file path exists on the user's
system.
[Link] actions
Clear clipboard
Remove any thing cut or copied to the clipboard. The
user will not be able to paste anything immediately
after this action.
Revision 3 Page 598/765
Set clipboard text
Set some text to be copied to the clipboard. This has
the same effect as if the user had selected the text in
a text box and selected 'Copy'. They can then paste
the text in to any other application.
Append file
Add some text to the end of the file. This is usually
faster than writing the full file again with some new
content at the end. Appending to files can be useful
for logging.
Copy file
Make an identical binary copy of a file at a new
location.
Create folder
Create a new folder on the user's local system.
Delete file
Delete a file from the user's local system. Be sure to
use this carefully, since a mistake could mean
deleting the wrong file.
List files
Read a list of every subfolder and file in a given
folder. After this action the ListCount and ListAt
expressions can be used to return the items in the
list.
Move file
Make an identical binary copy of a file at a new
location, then delete the old file. Note you should use
Revision 3 Page 600/765
the Rename file rather than the Move file action if
you intend to move it to a new name in the same
folder.
Open browser
Open the default browser on the system to a given
URL.
Rename file
Set a new name for an existing file path.
Run file
Run the file at an existing file path. This is analogous
to double-clicking the file in the OS file explorer. For
executable programs, it will attempt to run the
program; for other file types, it will open the default
associated program, such as the system default
image editor if an image file is given.
Write file
Write a text file to the user's local system. If the file
does not exist, it is created. If the file already exists,
its content is overwritten.
Maximize
Maximize the window on the user's desktop. It will
take up most (but usually not all) of the display.
Minimize
Minimize the window to the operating system start bar
or dock.
Revision 3 Page 601/765
Request attention
Perform an operating-specific activity to show
attention is required from the user, such as by
flashing the title bar of the window.
Restore
Restore the window to show it again after minimizing.
Set width
Set height
Set the dimensions of the window. Note this includes
the window title bar and borders, so the actual
displayed area of the game may be less than the
window size you set.
Set resizable
Enable or disable resizing of the window.
Set title
Set the text that appears in the title bar or caption of
the window.
Revision 3 Page 602/765
Set X
Set Y
Set the position of the window on the user's desktop,
in pixels relative to the top-left of the primary monitor.
Unmaximize
Undo a window maximize, restoring the window to its
previous size.
[Link] expressions
ClipboardText
The current text that the user has copied to the
clipboard, if any. This allows you to 'paste' the data
automatically.
ChosenPath
Return the path that was selected after On folder
dialog OK, On open dialog OK or On save dialog
OK.
AppFolder
Return the path to the application's folder, including
Revision 3 Page 603/765
the trailing slash. Read permission can be expected,
but write permission cannot be guaranteed (for
example the Program Files folder on Windows
requires administrator permission to write to).
DroppedFile
In On file dropped, the path to the file that was
dropped in to the application's window.
FileSize(path)
Return the size of a given file, in bytes.
ListAt(index)
After the List files action, returns the file or folder
name at the zero-based index in the list.
ListCount
After the List files action, returns the number of files
or folders in the list.
ReadFile(path)
Open the given file and return its text content as a
string. Note that each time this expression is used the
file is opened and read from disk. Therefore if the
expression is used twice, the file is opened and read
twice, which can impact performance. If necessary
first read the file to a variable, then reference the
variable multiple times.
UserFolder
Return the path to the user folder, which is typically
Revision 3 Page 604/765
where the user's documents and other personal files
are kept. Both read and write permissions can be
expected.
WindowWidth
WindowHeight
Retrieve the current size of the window in pixels. Note
this includes the window title bar and borders, so may
be larger than the display area of the game.
WindowTitle
Get the current text showing in the window title bar or
caption.
WindowX
WindowY
Get the current position of the window in pixels
relative to the top-left point of the user's primary
monitor.
Optimisation
Particle effects are more efficient than creating the
same effect with Sprite objects, but not by a large
margin. Just like with sprites, you should be aware that
creating a large number of particles can have a serious
performance impact on your game, especially on mobile.
Use the ParticleCount expression to monitor how many
particles are being created. On desktop systems, more
than a couple of hundred particles is likely to impact the
framerate. On mobiles, use of the Particles object is not
recommended at all since the framerate is usually
already limited by the existing sprites in the game; if
absolutely necessary, keep particle counts below 50 on
mobile for best performance.
Particle Properties
Revision 3 Page 609/765
The Particles object has a relatively many properties,
which are split in to three groups: particle spray
properties (relating to the Particles object itself), initial
particle properties (relating to the creation of each
individual particle) and particle lifetime properties
(relating to how particles behave after creation).
Spray cone
The number of degrees through which particles are
fired. This is represented by the red lines in the
Layout View. Use 360 to fire particles in all directions.
Type
The Particles object can work in two modes:
Continuous spray will create a constant spray of
particles (the default). One-shot will create a single
blast of particles, the total number set by Rate. Once
all particles have been destroyed, the Particles object
Revision 3 Page 610/765
then destroys itself. This is useful for one-off effects
like explosions or impacts.
Image
Click to open the Image editor to edit the particle
image. Try a spot on a transparent background, or on
a black background with the Additive effect.
Size
The initial size of each particle, in pixels. Particles are
always shown as squares.
Opacity
The initial opacity of each particle, from 0
(transparent) to 100 (opaque).
Grow rate
The initial grow rate (change in size over time) for
each particle, in pixels per second. 0 means the
particle will always stay the same size. A positive
value will make particles grow, and a negative value
will make particles shrink.
X randomiser
Y randomiser
Revision 3 Page 611/765
The initial offset to the particle's position. You can
make particles created along a line or in a box with
these properties.
Speed randomiser
A random adjustment to each particle's initial speed
on creation. For example, a value of 100 will change
each particle's initial speed by up to 50 pixels per
second faster or slower.
Size randomiser
A random adjustment to each particle's size on
creation. For example, a value of 20 will change each
particle's initial size by up to 10 pixels larger or
smaller.
Gravity
Revision 3 Page 612/765
The acceleration downwards caused by gravity, in
pixels per second per second. Useful for making
fountain or other falling particle effects. Set to 0 to
prevent gravity having any effect on particle
movement.
Angle randomiser
Maximum random change to each particle's angle
during its lifetime, in degrees per second. For
example, set to 0 to prevent particles ever changing
direction, or set to 10 to allow particles to change up
to 5 degrees left or right per second.
Speed randomiser
Maximum random change to each particle's speed
during its lifetime, in pixels per second per second.
For example, set to 0 to prevent the speed changing
randomly, or set to 100 to allow particles to speed up
or slow down by 50 pixels per second per second.
Opacity randomiser
Maximum random change to each particle's opacity
during its lifetime. Useful for creating "twinkling"
effects.
Destroy mode
How each particle is destroyed. There are three
modes available: Fade to invisible will fade each
particle's opacity to zero over the Timeout. When the
particle becomes invisible, it is destroyed. Timeout
expired simply destroys each particle after the
Revision 3 Page 613/765
Timeout has expired, without altering the opacity.
Particle stopped destroys each particle when its
speed reaches zero. You must take care to use a
negative Acceleration, or particles will never be
destroyed!
Timeout
The time in seconds particles last for before being
destroyed, depending on the Destroy mode .
Particle conditions
Is spraying
True if the particle spray is currently enabled.
Particle actions
Set spraying
Enable or disable the spray, when in Continuous
Revision 3 Page 614/765
spray mode. When disabled, no new particles are
created.
Particle expressions
ParticleCount
The number of particles the Particles object currently
has. This is important to ensure you are not creating
too many particles and slowing the game down; see
the Optimisation section above. Note that due to the
way Construct 2 expressions work, if you have
multiple Particle object instances, this will only return
the particle count for one of the instances - use a For
Each loop to count multiple instance's total particle
count.
Maximum
The maximum progress value, at which point the
progress bar is shown full indicating a completed
operation.
Tooltip
An optional tooltip to show while hovering the mouse
over the control.
Initial visibility
Whether the control is initially visible or invisible in
the page.
ID
An optional id attribute for the element in the DOM
(Document Object Model). This can be useful for
accessing the element's value from external scripts,
or styling with CSS in the HTML page.
Make indeterminate
Set the progress bar in to an indeterminate mode,
intended to indicate that it is working, but the
progress is unknown. The display of this mode
depends on the browser and platform. Not all
browsers may support an indeterminate mode for
progress bars.
Set maximum
Set the maximum progress value for the progress
bar.
Set progress
Set the current progress value displayed by the
progress bar, from 0 to the maximum.
Set tooltip
Set the tooltip that appears when the mouse hovers
over the control.
Progress
The currently set progress amount, if the bar is not in
indeterminate mode.
Setting up
To set up pubCenter ads:
pubCenter properties
Application ID
Ad unit ID
Paste in the relevant details from the pubCenter site.
pubCenter conditions
Is banner showing
Revision 3 Page 620/765
True if any banner is currently showing.
On interstitial cancelled
Triggered when a displaying interstitial ad is
cancelled.
On interstitial completed
Triggered when a displaying interstitial ad is
completed.
On interstitial error
Triggers when an error occurs displaying an
interstitial ad.
On interstitial ready
Triggers after Prepare interstitial when an interstitial
ad has finished loading in the background and is
ready to be displayed. After this trigger you can use
Show interstitial to display it.
pubCenter actions
Hide banner ad
Hide any currently showing banner.
Show banner ad
Display an ad with a given position and size.
Prepare interstitial
Start loading an interstitial ad in the background.
Revision 3 Page 621/765
When it finishes loading, On ready triggers.
Optionally another ad unit ID can be provided. If left
empty, it will use the ad unit ID from the object's
properties. Otherwise it uses the specified ad unit ID
for the interstitial.
Show interstitial
Display an interstitial ad that is ready. This should be
used in or after On ready.
pubCenter expressions
The pubCenter object has no expressions.
Shadow rendering
The Shadow light object renders shadows adjacent to
objects with the Shadow caster behavior, using the
object's collision polygon and the relative location of the
light. Shadows are filled in over the background, as
opposed to rendering sections of light. The Z order of
the Shadow light object determines whether the
shadows appear above or below other objects.
Shadow limitations
Due to the shadow rendering algorithm, there are a
couple of limitations:
Tags
By default, all shadow lights cast shadows off all
shadow casters. In some cases it is desirable to only
have certain shadow lights cast shadows off certain
shadow caster objects. Each shadow light object can be
Revision 3 Page 626/765
assigned a tag, and the Cast from property set to only
cast shadows from that object off shadow caster
behaviors with the same (or different) tags.
Light radius
The radius of the light. If the radius is 0, the light acts
like a point source and shadows are hard-edged. If
the radius is larger the object will render penumbras
at the edges of shadows. The larger the radius, the
wider the penumbras will be. For correct rendering
avoid using a large radius, and especially avoid
making the radius larger than any of the shadow
caster objects. If the radius is not 0, the light height is
ignored and shadows always extend offscreen.
Cast from
Which shadow caster objects to render shadows for
from this object. The options are: All: every shadow
caster object will get a shadow rendered for this light.
Same tag: shadows will only be rendered for shadow
casters with the same Tag property. Different tag:
shadows will only be rendered for shadow casters
Revision 3 Page 627/765
with a different Tag property.
Tag
Used to determine which shadow casters to render
shadows for, depending on the Cast from mode. If
Cast from is set to All, the tag is ignored.
Tag
Return the current tag of the object.
Step
The increment of possible values. For example if the
step is 10, then the slider will jump in units of 10 as it
is moved, and only a multiple of 10 can be chosen as
a value.
Tooltip
An optional tooltip to show while hovering the mouse
over the control.
Initial visibility
Whether the control is initially visible or invisible in
the page.
Enabled
Whether the control is initially enabled and usable, or
disabled so that it cannot be interacted with.
ID
An optional id attribute for the element in the DOM
(Document Object Model). This can be useful for
accessing the element's value from external scripts,
or styling with CSS in the HTML page.
On changed
Triggered when the user changes the chosen value
on the slider bar.
On clicked
Triggered when the user clicks the slider bar.
Set enabled
Enable or disable the control. If disabled, it cannot be
interacted with.
Set maximum
Set the maximum value that can be chosen from the
slider bar.
Set minimum
Set the minimum value that can be chosen from the
slider bar.
Set tooltip
Set the tooltip that appears when the mouse hovers
over the slider bar.
Set value
Set the currently selected value of the slider bar. This
must be between the currently set minimum and
maximum values.
Minimum
Return the currently set minimum slider value.
Step
Return the currently set slider step value (increment).
Value
Return the current value chosen by the user,
between the minimum and maximum values.
Sprite properties
Animations
Click the Edit link to open the Image and Animations
editor for the object. All instances of the object type
Revision 3 Page 634/765
share a single set of animations.
Size
Click the Make 1:1 link to size the selection at original
size (100%). This makes the width and height of the
object the same as its first animation frame image.
Initial visibility
Set whether the object is shown (visible) or hidden
(invisible) when the layout starts.
Initial animation
Set the initially displaying animation. If the animation
name is not found in the object, an arbitrary
animation is picked as the default.
Initial frame
Set the initially displaying animation frame from the
object's initial animation. This is a zero-based index,
so the first frame is 0. This can be useful for storing
different tiles or scenery in different animation frames
of a single Sprite object type.
Collisions
Enable or disable collisions for the object. Disabling
collisions means no collision events will register for
the object nor will any behaviors on the object register
collisions with solids or jump-thrus.
Sprite conditions
Revision 3 Page 635/765
For conditions in common to other objects, see
Common conditions.
Compare frame
Compare the current animation frame number, which
is a zero-based index (the first frame is 0).
Compare speed
Compare the speed of the current animation, in
animation frames per second. Animations which are
playing backwards (e.g. with ping-pong animations)
have a negative speed.
Is flipped
Is mirrored
True if the object has been flipped or mirrored with
the Set flipped or Set mirrored actions.
Is playing
True if a given animation is currently set. Animations
are identified by their name (case insensitive).
On any finished
Triggered when any animation reaches the end.
Looping animations do not finish.
On finished
Triggered when a given animation reaches the end.
Looping animations do not finish. Animations are
identified by their name (case insensitive).
Revision 3 Page 636/765
On frame changed
Triggered whenever the animation switches to
another frame while the animation is playing.
Collisions enabled
True if the object's collisions are currently enabled.
Sprite actions
For actions common to other objects, see Common
Revision 3 Page 637/765
actions.
Set animation
Change the currently playing animation to another
animation. Animations are identified by their name
(case insensitive). The new animation can either play
from the beginning or from the same frame number
as the last animation was on (current frame).
Set flipped
Set whether the object image appears vertically
flipped or normal. This also affects image points and
the collision polygon.
Set mirrored
Set whether the object image appears horizontally
mirrored or normal. This is useful for platform games.
Mirroring also affects image points and the collision
polygon.
Set frame
Set the current zero-based animation frame number
that is showing. The animation will continue to play at
its current speed.
Set speed
Set the playback rate of the current animation, in
animation frames per second. Instances can have
different animation speeds.
Start
If the current animation is stopped, start playing the
animation again. Playback can either resume from
the current frame, or restart from the beginning.
Stop
Stop the current animation from playing. The object
will be left showing the current animation frame.
Set scale
Sets the width and height to a multiple of the object's
Revision 3 Page 639/765
original size, similar to zooming the object
proportionally. For example, if the object is 50x100,
Set scale to 2 will set its size to 100x200, and Set
scale to 0.1 will set its size to 5x10.
Sprite expressions
For expressions common to other objects, see common
expressions.
AnimationFrameCount
The number of animation frames in the current
animation.
AnimationName
A string containing the name of the currently playing
animation.
AnimationSpeed
The current playback rate of the current animation, in
animation frames per second. If the animation is
playing backwards (e.g. ping-pong animations), the
animation speed is negative.
ImageWidth
ImageHeight
The original dimensions of the object (its current
animation frame image size), in pixels. Since objects
can be stretched at runtime causing the normal
Width and Height expressions to return different
values, these can be used to get the original size
regardless of the stretched size.
ImagePointCount
Return the number of image points on the currently
displaying animation frame of the object.
Revision 3 Page 641/765
ImagePointX
ImagePointY
Retrieve the position of an image point on the
currently displaying animation frame of the object.
You can pass either the zero-based index of the
image point, or a string of its name.
Character width
Character height
The size of each character's cell in the sprite font
image. Individual characters can be displayed with a
different width using the Set character width action.
In this case, the character should be drawn left-
aligned within its cell.
Character set
A string of characters that describes the sequence of
letters in the sprite font image. This is used to map
text to images. While the default starts with the
English alphabet, it could be changed to another
language or sequence and the image updated
accordingly. Note however the Sprite Font can only
display characters that are in the character set; any
characters not in the character set with a
corresponding image will appear as an empty space.
Text
The initial displaying text.
Scale
A multiplier to scale the rendered text with, such as
0.5 for half as big or 2 for twice as big. This can be
Revision 3 Page 645/765
used to "fake" different font sizes, but remember it's
only stretching images; you may want to draw the
font again at a different size instead of using a scale.
Initial visibility
Whether the object is initially visible or invisible when
the layout starts.
Horizontal alignment
The horizontal alignment of the text within the object
bounding rectangle.
Vertical alignment
The vertical alignment of the text within the object
bounding box.
Hotspot
Choose the position of the hotspot (or origin) of the
object relative to its unrotated bounding rectangle.
Wrapping
Choose word to only wrap entire space-separated
words when reaching the end of a line. Choose
Character to wrap at any character, which can break
some words across lines half way through, but is
more suitable for some languages.
Character spacing
Extra space in pixels to add horizontally between
characters.
Revision 3 Page 646/765
Line height
Extra space in pixels to add vertically between lines.
0 is the default size, negative values make lines
closer together, and positive values space lines out
further apart.
Set text
Replace the current text with a new string.
CharacterScale
CharacterSpacing
LineHeight
Return the corresponding object properties. For more
information, see Sprite font properties.
CharacterWidth(char)
Return the width of a character. A character must be
passed (as a string) so the Set character width
action can be taken in to account. Since the
expression can only return one value, if there are
multiple characters in the string, only the first is used.
Revision 3 Page 648/765
Text
Return the object's current text.
TextWidth
TextHeight
Return the size of the actual text content within the
text object's rectangle.
Text rendering
Different browsers render text in different ways, and
Construct 2's layout view also renders text differently to
other browsers. This means you should expect the
appearance of the Text object to vary slightly across
browsers.
Text properties
Text
The text for the object to initially be showing.
Initial visibility
Whether or not the object is shown (visible) or hidden
(invisible) when the layout starts.
Font
The font the text object uses to display its text. Click
the '... ' button to the right of the font name to open a
font picker dialog. Fonts chosen this way must be
installed to the user's computer for it to display
correctly. For this reason it is recommended to use
Web Fonts instead if you are choosing an
uncommon font.
Color
Choose the color of the text object's text.
Horizontal alignment
Choose whether the text displays left, center or right
aligned within its bounding rectangle.
Revision 3 Page 651/765
Vertical alignment
Choose whether the text displays top, center or
bottom aligned within its bounding rectangle.
Hotspot
Choose the position of the hotspot (or origin) of the
object relative to its unrotated bounding rectangle.
Wrapping
Choose how text wraps at the end of a line. Word will
wrap entire words separated by spaces or hyphens.
Character will wrap to the next line on any character,
which might split words in half in Western languages
but is more suitable for other languages like Chinese.
Line height
Amount to change the space between each line of
text, in pixels. Use 0 for the default amount, -5 for 5
pixels shorter than default, 10 for 10 pixels taller than
default, and so on.
Text conditions
For conditions common to other objects, see common
conditions.
Compare text
Test whether the text object is currently displaying a
certain string of text. The comparison can be either
case sensitive ("TEXT" is different to "text") or case
insensitive ("TEXT" is considered the same as
Revision 3 Page 652/765
"text"). To test if the text object is not showing some
text, invert the condition.
Text actions
For actions common to other objects, see common
actions.
Append text
Add some text to the end of the current text. For
example, if the text object contains Hello and has
World appended, the text object then contains
Revision 3 Page 653/765
HelloWorld.
Set text
Set the text the object is currently displaying. Use the
& operator to combine text and numbers. For more
information, see expressions.
Text expressions
For expressions common to other objects, see common
expressions.
Text
Return a string containing the object's current text.
TextWidth
TextHeight
Return the size of the actual text content within the
text object's rectangle. Note the Text object must be
drawn before these have the correct values. If you
set the text then immediately access these
expressions, they won't yet have the correct value.
Adding a 'Wait 0.1 seconds' action will usually solve
this.
Textbox properties
Text
The initial text entered in to the field.
Placeholder
Some text that appears faintly when the field is
empty. This can be used for hints for what the field is
for, e.g. Username.
Tooltip
A tooltip that appears if the user hovers the mouse
over the text box and waits. Leave blank for no tooltip.
Initial visibility
Whether or not the text box is shown on startup. If
Invisible, the field must be shown with the Set visible
action.
Enabled
Revision 3 Page 656/765
Whether the text box is initially enabled. If No, the
field will be greyed out and cannot be modified.
Read-only
Set whether the field is read-only, which means the
text cannot be modified but can still be selected. This
is different to disabling the field, where text cannot be
selected.
Spell check
Enable spell-checking on the text entered in to the
field, if the browser supports it. If enabled, spelling
errors are underlined with a squiggly red line.
Type
Set the type of content being entered in to the text
field, which can be: Text (any content) Password
(any content but characters hidden) Email (intended
for strings in the general format joe@[Link])
Number (numerical digits only) Telephone number
(telephone number characters only) URL (web
addresses in the general format [Link]
Textarea (multi-line text input) The email, number,
telephone number and URL types are generally most
useful for mobile devices, since they change which
type of on-screen keyboard appears when the field is
focused. For example, Text will show a general
purpose on-screen keyboard, whereas Number may
show a simple number pad, making it more
convenient for the user to enter the content.
Revision 3 Page 657/765
Auto font size
Automatically set the font-size property of the
element according to the layout and layer scale. This
will prevent the font-size CSS property being
manually set with the Set CSS style action. Set to No
if you intend to use Set CSS style to adjust the font-
size property.
ID
(optional) An optional id attribute for the element in
the DOM (Document Object Model). This can be
useful for accessing the element's value from
external scripts, or styling with CSS in the HTML
page.
Textbox conditions
Compare text
Compare the text currently entered in to the field. The
comparison can either be case sensitive ("TEXT" is
different to "text") or case insensitive ("TEXT" is the
same as "text").
On clicked
Triggered when the user clicks the field.
On double-clicked
Triggered when the user double-clicks the field.
On text changed
Revision 3 Page 658/765
Triggered whenever the text in the field is modified,
by typing, backspace/delete, cut/paste etc.
Textbox actions
Set CSS style
Set a CSS (Cascading Style Sheets) style on the
Textbox element. For more information, see the
section Styling Textbox objects. Note that if the Auto
font size property is set to Yes, any changes to the
font-size property will be overridden.
Scroll to bottom
Scroll to the bottom of the control. Only has an effect
when set to the textarea type, since it is the only
multiline mode. This is useful for chat or log style
textareas.
Set enabled
Set the field enabled or disabled. When disabled, the
field appears greyed out and cannot be modified.
Set focused
Set the input focus to the field. The text caret will
begin flashing ready for text entry.
Set placeholder
Set the text that appears faintly when the field is
empty. This can be used for hints for what the field is
for, e.g. Username.
Revision 3 Page 659/765
Set read-only
Set whether the field is read-only, which means the
text cannot be modified but can still be selected. This
is different to disabling the field, where text cannot be
selected.
Set text
Set the text currently entered in to the field.
Set tooltip
Set the text that appears for the field tooltip. Leave
blank for no tooltip.
Set unfocused
Remove the input focus from the field.
Textbox expressions
Text
Get a string containing the text currently entered in to
the field.
Power-of-two sizes
Revision 3 Page 661/765
For best results, use a power-of-two sized square image
for the Tiled Background (e.g. 16x16, 32x32, 64x64,
128x128...). This achieves best results in WebGL
mode. The object will still work correctly with non power-
of-two sized images, but the quality may be slightly
reduced since the image has to be stretched to a power-
of-two size before tiling. (Note this does not apply to
Sprite objects, which can use any size.)
Initial visibility
Choose whether the object is shown (visible) or
hidden (invisible) when the layout starts.
Hotspot
Choose the position of the hotspot (or origin) of the
object relative to its unrotated bounding rectangle.
Collisions
When testing for collisions with a Tilemap object, empty
(erased) tiles count as not colliding, and all other tiles
count as colliding. A custom collision polygon can be set
for individual tiles by clicking the Edit tile collision
polygon button in the Tilemap bar, or just double-
clicking the tile in the Tilemap bar. Note however the
collision polygon cannot be entirely removed from a tile:
only an erased tile counts as not colliding at all.
Tile IDs
Each tile in the tileset has a zero-based index to identify
it. This starts with the top-left tile and increments
horizontally in rows. The tile ID can easily be seen by
hovering the mouse over a tile in the Tilemap Bar. The
tile ID is useful for comparing or setting tiles at runtime
with the object's conditions, actions and expressions.
Revision 3 Page 665/765
Tile positions
When using tiles in the object's conditions, actions and
expressions, positions are generally given in tiles
instead of layout co-ordinates. You can convert between
tile positions and layout co-ordinates using the
PositionToTileX/Y and TileToPositionX/Y expressions.
Tilemap Properties
Image
Click the Edit link to edit the tileset image from which
Revision 3 Page 666/765
tiles are drawn.
Initial visibility
Choose whether the object is visible or invisible at the
start of the layout.
Tile width
Tile height
The size of tiles in the tilemap, in pixels. It is
recommended to use a square power-of-two size
(e.g. 32x32).
Tile X offset
Tile Y offset
The offset in pixels of the top-left tile in the tileset
image. This is not normally necessary and is
provided mainly for compatibility with existing tileset
images that have the tiles drawn at an offset.
Tile X spacing
Tile Y spacing
The spacing in pixels between tiles in the tileset
image. This is not normally necessary and is
provided mainly for compatibility with existing tileset
images that have the tiles drawn apart from each
other.
Seamless mode
Use a rendering mode that prevents seams
appearing between tiles, but also disables some
tilemap optimisations which could reduce
Revision 3 Page 667/765
performance. Turning Seamless mode off can
improve performance, but may show seams if the
following project properties are not as follows:
Letterbox integer scale fullscreen mode, Point
sampling, and Pixel rounding on. NOTE: you cannot
use different Seamless mode settings on different
instances of the same Tilemap object, even across
layouts. For correct display, all tilemap instances of
the same object type should use the same Seamless
mode.
Tilemap conditions
Compare tile at
Compare the tile ID at a position in the tilemap.
Tilemap actions
Download
Invoke a download of the current tilemap data (from
the TilesJSON expression) as a JSON file. This can
be useful for in-game level editors.
Revision 3 Page 668/765
Load
Load the current tiles from a string of JSON data
from a previous use of the TilesJSON expression.
Erase tile
Erase the tile at a position.
Set tile
Set the tile at a position in the tilemap by its tile ID.
The tile that is set can also optionally be flipped or
rotated.
Tilemap expressions
TilesJSON
Retrieve the tile data in JSON format, which can be
loaded in again later using the Load action. Note this
differs from the built-in AsJSON expression, which
returns the entire object state (including position,
size, behaviors etc), whereas TilesJSON returns only
the tile data.
PositionToTileX(x)
PositionToTileY(y)
Convert an X or Y layout co-ordinate in to the
corresponding tile number in the tilemap. For
example, this can be used to get the tile position
under the mouse.
SnapX(x)
SnapY(y)
Snap an X or Y layout co-ordinate to the nearest tile.
This also returns a layout co-ordinate, but aligned to
the nearest tile in the tilemap.
Revision 3 Page 670/765
TileAt(x, y)
Return the tile ID at a position in the tilemap. Note the
position is given in tiles, not layout co-ordinates. If the
tile at the given position is empty (has been erased),
the expression returns -1.
TileToPositionX(x)
TileToPositionY(y)
Convert a tile position to layout co-ordinates. For
example, this can be used to position a Sprite object
on top of a given tile.
Multi-touch
The Touch object supports multi-touch. This is most
useful with the On touched object and Is touching
Revision 3 Page 672/765
object conditions, which can for example detect if
multiple on-screen touch controls are being used. This
is sufficient for many games.
Touch properties
Use mouse input
If set to Yes, mouse clicks will simulate touch events.
Clicking and dragging the left mouse button will
simulate a touch along where mouse dragged, and
single clicks will simulate taps. This can be very
useful for testing touch events work properly on a
desktop computer with no touch input supported.
However, only single-touch input can be simulated
with a mouse, and a mouse is much more precise
than a touch, so it is still best to test on a real
touchscreen device.
Touch conditions
On double-tap
Revision 3 Page 673/765
On double-tap object
Triggered when two tap gestures are performed in
quick succession in the same location. The On
double-tap object variant triggers when this gesture
is performed over an object.
On hold
On hold over object
Triggered when a touch is held (pressed and not
moved) for a short time period. The On hold over
object variant triggers when this gesture is performed
over an object.
On tap
On tap object
Triggered when a tap gesture is performed, which is
defined as a touch and release in quick succession in
the same location. The On tap object variant triggers
when this gesture is performed over an object.
Compare acceleration
Compare the current device's motion as its
acceleration on each axis in m/s^2 (meters per
second per second). The effect of gravity can be
included or excluded, but note that some devices only
support accelerometer values including the effect of
gravity and will always return 0 for acceleration
excluding gravity.
Compare orientation
Revision 3 Page 674/765
Compare the device's current orientation, if the
device has a supported inclinometer. Alpha is the
compass direction in degrees. Beta is the device
front-to-back tilt in degrees (i.e. tilting forwards away
from you if holding in front of you). A positive value
indicates front tilt and a negative value indicates back
tilt. Gamma is the device left-to-right tilt in degrees
(i.e. twisting if holding in front of you). A positive
value indicates right tilt and a negative value
indicates left tilt.
Is in touch
True if any touch is currently in contact with the
screen.
Is touching object
True if any touch is currently touching a given object.
Revision 3 Page 675/765
On any touch end
Triggered when any touch releases from the screen.
On touched object
Triggered when a given object is touched.
Touch actions
The Touch object has no actions.
Touch expressions
AccelerationX
AccelerationY
AccelerationZ
Revision 3 Page 676/765
Get the current device's motion as its acceleration on
each axis in m/s^2 (meters per second per second)
excluding the effect of gravity. The expressions
which include gravity (below) are more widely
supported; these will return 0 at all times on devices
which do not support them.
AccelerationXWithG
AccelerationYWithG
AccelerationZWithG
Get the current device's motion as its acceleration on
each axis in m/s^2 (meters per second per second)
including the acceleration caused by gravity, which is
about 9.8 m/s^2 down at all times. For example, at
rest, the device will report an acceleration downwards
corresponding to the force of gravity. These
expressions are more commonly supported than the
expressions returning acceleration without G (above).
However, devices are still not guaranteed to support
motion detection, in which case these will return 0 at
all times.
Alpha
Beta
Gamma
Return the device's orientation if supported, or 0 at all
times if not supported. Alpha is the compass direction
in degrees. Beta is the device front-to-back tilt in
degrees (i.e. tilting forwards away from you if holding
in front of you). A positive value indicates front tilt and
a negative value indicates back tilt. Gamma is the
Revision 3 Page 677/765
device left-to-right tilt in degrees (i.e. twisting if
holding in front of you). A positive value indicates
right tilt and a negative value indicates left tilt.
AbsoluteX
AbsoluteY
AbsoluteXAt(index)
AbsoluteYAt(index)
AbsoluteXForID(id)
AbsoluteYForID(id)
Return the current position of a touch over the
canvas area. This is (0, 0) at the top left of the
canvas and goes up to the window size. It is not
affected by any scrolling or scaling in the game. The
At expressions can return the absolute position of
any touch given its zero-based index, and the ForID
expressions return the position of a touch with a
specific ID.
X
Y
XAt(index)
YAt(index)
XForID(id)
YForID(id)
Return the current position of a touch in layout co-
ordinates. It changes to reflect scrolling and scaling.
However, if an individual layer has been scrolled,
scaled or rotated, these expressions do not take that
in to account - for that case, use the layer versions
below. The At expressions can return the position of
Revision 3 Page 678/765
any touch given its zero-based index, and the ForID
expressions return the position of a touch with a
specific ID.
X("layer")
Y("layer")
XAt(index, "layer")
YAt(index, "layer")
XForID(id, "layer")
YForID(id, "layer")
Return the current position of a touch in layout co-
ordinates, with scrolling, scaling and rotation taken in
to account for the given layer. The layer can be
identified either by a string of its name or its zero-
based index (e.g. Touch.X(0)). The At expressions
can return the position of any touch on a layer given
its zero-based index, and the ForID expressions
return the position of a touch with a specific ID.
TouchCount
Number of touches currently in contact with the
device's screen.
TouchID
Return the unique ID of a touch (which is an arbitrary
number) in an event like On any touch start or On
any touch end.
TouchIndex
Return the zero-based index of the touch in an event
like On any touch start or On any touch end.
Revision 3 Page 679/765
AngleAt(index)
AngleForID(id)
Get the angle of motion of a specific touch in degrees
by its zero-based index or unique ID. A touch must
be moving across the device screen for this
expression to contain a useful value.
WidthForID(id)
HeightForID(id)
Return the width and height of a touch with a given
ID in pixels. This allows the app to determine the
approximate size of the touch area. Note some
platforms do not support this and will always return 0
for the touch size.
PressureForID(id)
Return the pressure of a touch with a given ID, as a
number from 0 (least detectable pressure) to 1 (most
detectable pressure). This is useful for devices with
pressure-sensitive displays, such as the iPhone 6S.
Note however not all devices have pressure-sensitive
displays, and so will always return 0 for the pressure.
SpeedAt(index)
SpeedForID(id)
Get the speed of a specific touch by its zero-based
index or unique ID. Touch speed is measured in
canvas pixels per second, so is not affected by
scaling the display.
Twitter properties
Type
One of the following button types: Follow: a 'Follow'
button to follow a Twitter account. The Share
property should be the name of the Twitter account to
follow, but without the @, e.g. Scirra to follow the
account @Scirra. Share: a 'Tweet' button to share a
URL. The Share property must be a valid URL, e.g.
[Link] The initial tweet text is set to
the Text property, optionally displaying as Via a given
account, with optional Hashtags. Mention: a button to
Revision 3 Page 681/765
send a public tweet to another account. The Share
property should be the name of the Twitter account to
tweet to, without the @. The initial tweet text is set to
the Text property, optionally displaying as Via a given
account, with optional Hashtags. Hashtag: a button
to tweet with a hashtag. The Share property should
be the hashtag to tweet with, without the [#] (e.g.
Scirra to tweet with hashtag [#]Scirra). Additional
hashtags can be added with the Hashtags property.
The initial tweet text is set to the Text property,
optionally displaying as Via a given account.
Share
The account to follow or mention, URL to share, or
hashtag to tweet, depending on Type.
Text
The initial text to have in the tweet, which is selected
so the user can easily replace it. This is not used
when the Type is Follow.
Via
Optionally display the tweet as being via another
twitter account, e.g. via @Scirra. The account should
be set in this property without the @, e.g. Scirra to
tweet via @Scirra. This is not used when the Type is
Follow.
Hashtags
Comma-separated hashtags to add to the tweet,
without the [#] (e.g. construct2,html5 to add the
Revision 3 Page 682/765
hashtags [#]construct2 [#]html5). This is not used
when the Type is Follow. When the Type is
Hashtag, the actual hashtag to share must be
entered in the Share property instead, but this
property can then be used to add extra hashtags to
the tweet.
Initial visibility
Whether the button is initially visible or invisible.
Count
For Follow or Share buttons, which direction to show
the count of how many users already follow or have
already shared, or None to not show any count.
Size
Whether to use a medium or large style button.
Language
An ISO 639-1 language code to use for the button,
which affects the text appearing on the button and in
the popup window.
Twitter conditions
On button loaded
Reload
Reload the button, so any changed properties then
take effect.
Twitter expressions
The Twitter plugin does not have any of its own
expressions.
In the layout
The User Media object appears as a rectangle in the
Revision 3 Page 685/765
layout view, represented by a red cross. This represents
where the video feed will be displayed in the layout. If
you only need microphone input, place the User Media
object outside the layout.
Is recognising speech
True if a speech recognition request has been
approved, and speech input through a microphone is
actively being recognised.
Is speaking
True if the speech synthesis engine is currently
reading out some text.
Request microphone
Show a security prompt to the user requesting that
they give the application permission to use
microphone input. On media request approved or On
media request declined will trigger depending on
their decision. The Audio object must also be in the
project, and Advanced audio supported to be true,
for this to be useful. A tag is given for the microphone
input, and the audio input from the microphone is
routed the same way as playing a sound with that tag.
This means you can assign effects from the Audio
object to the microphone input by adding the effects
to the same tag assigned to the microphone. A useful
combination is to add an analyser effect then a mute
effect to microphone input. This prevents the user
hearing their own voice, but allows peak, RMS and
Revision 3 Page 690/765
spectrum monitoring with the analyser. The specific
microphone input to use can be chosen with the
Source parameter, if media source listing is
supported and a media source list has been
requested; otherwise the default microphone input is
used.
Snapshot
If the user has approved a camera request and the
User Media object is showing a video feed, then
snapshots the current frame. The still image is then
available from the SnapshotURL expression as a
data URI representing the image. The image can be
loaded in to a Sprite or Tiled Background object using
the Load image from URL action and passing
SnapshotURL. This action optionally takes
parameters allowing you to specify the compression
format, which is useful if you intend to upload or save
the image and a smaller file size would be
advantageous.
Stop
Ends any active video feed or microphone input.
Media input must be requested again before it can be
used.
Pause speaking
Resume speaking
Pause or resume text being read out by speech
synthesis from the Speak text action.
Speak text
Read out some text using speech synthesis (also
Revision 3 Page 692/765
known as text-to-speech). The language, volume,
rate and pitch of the voice that reads out the text can
be customised. The Voice URI can be used to select
a different kind of voice (e.g. male vs. female) from a
list of the supported voices, if any alternatives are
available. The list of possible voices can be retrieved
using the VoiceCount and VoiceURIAt expressions.
Stop speaking
Stop reading out text from a previous Speak text
action. The speech cannot be resumed.
CanvasRecordingURL
After On canvas recording ready triggers, this is the
URL to the video recording that was made. Typically
this will be downloaded by using the Browser object's
Invoke download action to download this URL.
FinalTranscript
If speech recognition is active, returns the final
transcript of confirmed results. This does not change,
other than to add newly spoken words which have
also been confirmed.
Revision 3 Page 693/765
InterimTranscript
If speech recognition is active, returns the interim
transcript of results. The Request speech
recognition action must have specified Interim for the
Results parameter. The text of this expression can
change, as the speech recognition engine uses the
sound input in real-time to refine the results and
correct any misinterpreted words. Once the user has
spoken far enough for the speech recognition engine
to be confident of a final result, the word will
disappear from InterimTranscript and be appended to
FinalTranscript.
SpeechError
In On speech recognition error, contains a string
which identifies the type of error. Possible values are:
"no-speech", "aborted", "audio-capture", "network",
"not-allowed", "service-not-allowed", "bad-
grammar", or "language-not-supported". The most
common errors are "not-allowed" if the user declined
the permission prompt; "audio-capture" if no
microphone is present; or "network" if the speech
recognition is implemented by a remote server over
the Internet which is currently unavailable.
VoiceCount
Return the number of voices available for use with
speech synthesis.
VoiceLangAt(i)
VoiceNameAt(i)
Revision 3 Page 694/765
VoiceURIAt(i)
Return the language, name, or URI of the voice at
the given zero-based index. This can be used to
show the user a list of possible voices to choose. To
select a different voice, pass the appropriate voice
URI to the Speak text action.
AudioSourceCount
After On retrieved media sources triggers, the
number of audio sources available.
AudioSourceLabelAt(index)
After On retrieved media sources triggers, the label
of the audio source at the given index. The label is
normally the name of the input or recording device,
but it may be empty for security reasons (such as if
the user has not yet approved a media request).
CameraSourceCount
After On retrieved media sources triggers, the
number of camera sources available.
CameraSourceFacingAt(index)
After On retrieved media sources triggers, a string
indicating which way a camera source is facing. This
can be "user" (the camera is facing the user, such as
the front-facing camera on a phone), "environment"
(the camera is facing away from the user, such as
the back-facing camera on a phone), "left", "right", or
empty if unknown or withheld for security reasons.
Revision 3 Page 695/765
CameraSourceLabelAt(index)
After On retrieved media sources triggers, the label
of the camera source at the given index. The label is
normally the name of the input device, but it may be
empty for security reasons (such as if the user has
not yet approved a media request).
SnapshotURL
A data URI representing the snapshotted image after
a Snapshot action, otherwise an empty string. The
image can be loaded in to a Sprite or Tiled
Background object using the Load image from URL
action and passing SnapshotURL. Alternatively, the
data URI can be sent to a server, saved to disk,
downloaded with the Browser object, or anything else
you would like to do with it.
VideoWidth
VideoHeight
If a video feed is approved and active, this returns the
size in pixels of the feed from the device (which may
not be the same size as the object in the layout). If no
feed is active then 0 is returned.
Video formats
As with audio, browser makers have not been able to
agree on one video format that can play everywhere. As
a result to guarantee that video playback will work on all
browsers and on all platforms, it is necessary to encode
your videos in at least two formats.
Importing video
Due to the complexities of video compression and the
patent-encumbrance of h.264, Construct 2 does not
provide a video importer like it does with audio. You
must encode your video files yourself, and then import
them as project files. WebM and Ogg Theora are free
formats and you should be able to find free encoders,
whereas h.264 encoders may involve a fee.
Compatibility
On Safari for iOS and Chrome for Android, video
playback cannot begin unless triggered by a user input
event. The Play action will work in a user input trigger
like On touch start, but if done outside of that it cannot
play right away. To work around this the video plugin will
wait until the next touch event to start playing the video.
Revision 3 Page 698/765
This also applies to autoplaying videos: it will not start
until the first touch.
Video properties
WebM source
Ogg Theora source
H.264 source
Names of the project files for the video in different
formats. For more information, see Video formats
above.
Autoplay
The autoplay or preload mode. This can be: No:
nothing is done until the video is requested to be
played. Preload: on startup the video will start
downloading the video data, but will not start playing it
yet. This can allow video playback to start more
quickly when requested. Some platforms (e.g. mobile
devices on cellular data connections) may ignore this.
Yes: on startup the video will start downloading the
video data, and also start playing it as soon as it
determines the progress and transfer rate are
sufficient to play through to the end without stalling
Revision 3 Page 699/765
for buffering. Some mobile platforms will not start
playing until the first touch event - see Compatibility
for more information.
Play in background
If No, then switching browser tab, minimising the
browser window, switching to a different mobile app,
or otherwise hiding the window will pause the video
and resume it when switching back. This is intended
to avoid annoying the user with continued audio
playback when deciding to do something else, and it
also helps save battery on mobile devices. However
for some types of app it may be desirable to keep
playing in the background, in which case setting to
Yes allows continued playback even when in the
background.
Initial visibility
Whether the video is initially visible or invisible. Note
that if it is invisible, audio playback may still be heard
when playing, so it may be desirable to also mute the
video.
Video conditions
Has ended
True if the video playback has reached the end of the
video and stopped.
Is muted
True if the audio playback from the video has been
Revision 3 Page 700/765
muted.
Is paused
True if the video playback has been paused.
Is playing
True if the video playback is actively playing.
On playback event
Triggers when a playback event occurs. This can be
one of: Can play: triggered when enough data is
available to play at least a couple of frames, but there
may not be enough data to play through to the end.
Can play through: triggered when the browser
determines that the load progress and transfer rate
are sufficient for playback through to the end without
stalling for buffering. However this is not a guarantee,
since the transfer rate could drop or be cut off
completely. Ended: triggered when playback reaches
the end of the video. Error: triggered if an error
occurs during video loading, decoding or playback.
Started loading: triggered when the browser begins
loading video data. Played: triggered when playback
begins. Paused: triggered upon pausing the video
playback. Stalled: triggered if the video download rate
is too slow to keep up the current playback rate. This
will cause the video to pause while it finishes loading
the rest of the video, also known as buffering.
Video actions
Revision 3 Page 701/765
Pause
Pause the video playback if it is currently playing.
Play
Start playing the video. On some platforms this can
only happen in a user input event. For more
information, see the section on Compatibility.
Set looping
Set whether the video is looping, so that it restarts
from the beginning when it reaches the end.
Set muted
Set whether the audio playback from the video is
muted (inaudible) or unmuted.
Set source
Set a different video file to play. As with the object
properties, three formats can be specified. Setting the
source does not automatically start playing the video;
use the Play action to start it after changing the
source.
Video expressions
Duration
The video duration in seconds, if the video has
loaded enough for this to be determined.
PlaybackTime
The current playback time in seconds.
Volume
The current audio playback volume in dB attenuation.
WebSocket properties
The WebSocket object has no properties.
WebSocket conditions
Is connecting
True if currently in the process of establishing a
connection to a server. The connection is not yet
successfully established; there may still be an error.
Is open
True if a connection has been successfully
established and the communication channel is
currently open.
Revision 3 Page 705/765
Is supported
Use before attempting any connections to verify the
current browser or platform supports WebSockets.
On closed
Triggered when the connection is closed, either
deliberately or due to an error. The CloseCode and
CloseReason expressions can indicate why the
connection was closed.
On error
Triggered when an error occurs in the WebSocket
connection. Use the ErrorMsg expression to get the
error message text.
On opened
Triggered when the connection is successfully
established and the communication channel is now
open.
On message
Triggered when a text message arrives from the
server over an open connection. Use the
MessageText expression to retrieve the content of
the message.
WebSocket actions
Close
Close any active connection. No more messages can
Revision 3 Page 706/765
be sent or will be received after closing.
Connect
Connect to a WebSocket server. WebSocket server
addresses typically start with ws:// for non-secure
transmission and wss:// for secure transmission.
Note some network configurations may require
secure transmission in order to function correctly.
The Protocol parameter may be optionally set to a
required sub-protocol (sent with the Sec-WebSocket-
Protocol header in the WebSocket handshake). If the
server does not indicate it supports the chosen sub-
protocol, the connection will fail to be established.
This can be used to prevent the client connecting to
WebSocket servers that do not understand your
application's specific messages.
Send text
Send a text string to the server. This is ignored if the
connection is not currently open.
WebSocket expressions
CloseCode
In the On closed trigger, returns the numeric code of
the close reason. This can be one of the standard-
specified return values, or a user-defined value.
CloseReason
In the On closed trigger, returns a string describing
the reason the connection was closed. This is
Revision 3 Page 707/765
optional and may be empty.
ErrorMsg
In On error, the error message text.
MessageText
In On message, the text content of the message just
received from the server.
WebStorage conditions
Compare key value (as number)
Compare the value of a given key to a number. Since
the WebStorage object only stores values as strings,
this condition will first convert the value to a number,
then compare it. If the key value is not a number, the
condition will always be false.
On quota exceeded
Most browsers limit the amount of data that can be
stored in WebStorage to about 5mb. If this limit is
exceeded, or the user declines to increase the
storage limit if the browser prompts them, then On
quota exceeded runs. You will not be able to add any
new keys, or set existing keys to longer values, until
you delete some other values or clear the storage
entirely.
WebStorage actions
Clear local/session storage
Reset either local or session storage to empty for this
domain, with no data stored.
Load JSON
Load local storage keys and values from JSON data.
The Dictionary object's JSON format is compatible,
so data can be interchanged between Dictionary and
WebStorage, but note WebStorage only stores
strings (so all numbers will be converted to strings
when loading). If Mode is Set, local storage is first
cleared, then the data loaded. If Mode is Merge, the
keys in the JSON data are added or overwritten to
the existing keys in storage.
WebStorage expressions
LocalAt
SessionAt
Return the value at a zero-based index if all the keys
in storage are listed in alphabetical order. Useful for
listing all stored data.
LocalCount
SessionCount
Return the number of keys that exist in storage for
this domain.
LocalKeyAt
SessionKeyAt
Return the key name at a zero-based index if all the
keys in storage are listed in alphabetical order. Useful
for listing all stored data.
Revision 3 Page 713/765
LocalValue
SessionValue
Retrieve the value stored for a key in storage. If the
key does not exist this returns an empty string.
AsJSON
Return the entire contents of local storage in JSON
format. The result can also be loaded in to the
Dictionary object, but note WebStorage only stores
strings so all result values in the Dictionary object will
also be strings.
Roaming data
The object's features to use roaming data are designed
to be used the same way as the WebStorage object.
Familiarity with WebStorage will make it easier to use
the roaming data features. The main difference between
WebStorage and roaming data is that in Windows Store
Revision 3 Page 715/765
apps, roaming data is synced between all the user's
devices.
Test mode
Enabling the Test mode property of the Windows Store
object allows you to test purchases work before
publishing to the Windows Store and without having to
spend any money. However you must turn Test mode
off before submitting to the Windows Store, otherwise
your app will be rejected.
Is expired trial
Test if the app is in trial mode, and the trial period has
expired. This condition is subject to Test Mode.
Is licensed
Test if the app has been successfully purchased by
Revision 3 Page 717/765
the current user and has a valid license. This
condition is subject to Test Mode.
Is trial
Test if the app is in trial mode, and the trial is active
(the trial period has not expired). This condition is
subject to Test Mode.
On failed purchase
Triggered after a purchase attempt is cancelled or
otherwise completes unsuccessfully.
On license changed
Triggered when the license state of the app has
changed, such as going from trial to licensed, or trial
to expired trial. This condition is subject to Test
Mode.
On successful purchase
Triggered after a purchase attempt completes
successfully. Either the app or a new product is now
owned by the user.
On data changed
Triggered when the roaming data has been updated
with data from another device. Typically this happens
Revision 3 Page 718/765
when saving roaming data on one device, then the
user switches to another device, and runs the same
app again. There may be a delay before roaming data
syncs up, and when it is ready this trigger fires.
On share
Triggered when the user activates the Share charm.
In order to specify what to share, use one of the
sharing actions in this trigger.
Is Windows 8 app
True if currently running specifically as a Windows 8
app, otherwise false. Note this condition tests
specifically Windows 8 - it is not true on Windows 10,
even though it supports Windows Store apps. You
may prefer to use the Is Windows Store app
condition instead.
Purchase app
Prompt the user to purchase the app. You should
only use this action when the user expects it, such as
when they pressed a 'Purchase' button. If the
purchase is successful, On successful purchase and
On license changed are triggered. Otherwise On
failed purchase is triggered. This action is subject to
Test Mode.
Purchase product
Prompt the user to purchase a specific product ID
(case sensitive). You should only use this action
when the user expects it, such as when they pressed
a 'Purchase' button. If successful, On successful
purchase triggers; otherwise On failed purchase
triggers. This action is subject to Test Mode.
Fail share
Only valid in an On share event. Use this action to
indicate sharing failed or is currently unavailable.
Share HTML
Only valid in an On share event. Use this action to
share some HTML formatted text from the
application.
Share link
Only valid in an On share event. Use this action to
share a link, such as the address of your website,
from the application.
Share text
Only valid in an On share event. Use this action to
share some plain text from the application.
Show share UI
Bring up the Windows 8 Share UI automatically. Note
this was removed in Windows 10. Be sure to use this
with care in a way that will not offend or come across
as obnoxious to your users. For example a sensible
use is a custom Share button in your application
which brings up the Share UI. This action only works
when your app is in the foreground.
RoamingValue(key)
Retrieve a value from roaming storage associated
with the given key. If the key does not exist, an empty
string is returned. Note all values are returned as
strings, even if they were originally passed as
numbers.
AppFormattedPrice
After On store listing received triggers, returns the
price and currency of the app formatted for the user's
region.
ProductFormattedPrice
After On store listing received triggers, returns the
price and currency of a product ID formatted for the
user's region.
Revision 3 Page 723/765
ProductName
After On store listing received triggers, returns the
user-friendly name of a product from its ID.
The XML plugin can parse and read data from XML
documents. It uses XPath to access the XML
document. XPath is a kind of query language for XML,
similar to how SQL is a query language for databases.
To learn more about XPath, see the following links:
Internet Explorer
Internet Explorer does not support XPath queries that
return a number, e.g. count(...). In this case you can
use the NodeCount expression instead. Be sure to test
your project works in a range of browsers, which is a
best practice anyway. All other browsers have fully
standards-compliant XPath support.
XML conditions
For each node
Repeat the event once for each node returned by an
XPath query. Typically this will be used with a query
that returns multiple nodes, e.g. "/bookstore/book" to
select all "book" nodes under "bookstore". In the For
each node event, the current node is set to the one
currently being iterated. This means relative XPaths,
like "title/text()", work relative to the current node (in
this case returning the text of the child "title" tag). For
each node can also be nested, so you can iterate
another list relative to the current node.
XML actions
Load
Load an XML document from a string. See 'Loading
an XML document' above.
NumberValue
Return a number from an XPath expression. If
multiple values are returned, only the first value is
retrieved. In a For each node event, the XPath is
relative to the current node.
StringValue
Return a string from an XPath expression. If multiple
values are returned, only the first value is retrieved.
In a For each node event, the XPath is relative to the
current node.
System conditions
System actions
System expressions
Angles
Note angles in Construct 2 start with 0 degrees facing
right and increment clockwise.
Is between angles
True if a given angle is between the two other angles
in degrees. The first and second angles must be in
clockwise order. That is, X is between 0 and 45
degrees is true if the angle X is in a 45 degree area,
but X is between 45 and 0 degrees is true if X is in
the 315 degree area from 45 degrees through 0
degrees. The first angle is inclusive, but the second
angle is exclusive, to ensure adjacent ranges are
handled correctly.
Is clockwise from
True if a given angle is clockwise from another angle
Revision 3 Page 729/765
in degrees, or in other words, if it is 180 degrees or
less in a clockwise direction from Angle 2 to Angle 1.
Invert to test if anticlockwise instead. For example, 45
degrees is clockwise from 0 degrees, but 0 degrees
is anticlockwise from 45 degrees. Angle 1 is the
angle to test, and Angle 2 is the reference angle to
test whether Angle 1 is clockwise from.
Is within angle
True if an angle is within a number of degrees of
another angle. This is more reliable than testing if an
angle exactly equals an angle, e.g. X within 0.5
degrees of 90 degrees is probably better than X
equals 90 degrees, since there are many cases an
angle can be very close to, but not exactly, 90
degrees.
General
Compare two values
Compare any two expressions (which can either
numbers or text) with each other. They can be
compared as Equal, Not equal, Less, Less or equal,
Greater or Greater or equal.
Every tick
A condition which is always true. Used on its own,
this has the same effect as running every time it is
checked, which is once per tick, hence the name
"Every tick". This is about 60 times a second on most
computers; see how events work for more
Revision 3 Page 730/765
information. Adding Every tick to an event with other
conditions is redundant and has no effect at all.
Is between values
Test if a number is between two values (greater or
equal to a lower value and less or equal to a higher
value).
Is group active
Test if a group of events is active or inactive. The
name of the group is used to identify it.
Is number NaN
Test if a number is equal to NaN (Not A Number), a
special value returned by calculations which cannot
be represented as a real number, such as the square
root of -1.
Is value type
Check if a value is a number or a string.
Test regex
Test if a given string matches a regular expression
with flags. This only returns a true or false result, so
to make more advanced use of regular expressions,
see the Regex... system expressions.
Revision 3 Page 731/765
Global & local variables
Compare variable
Compare the value of a event variable (a global
variable or local variable in scope). Event variables
can store both numbers and text. The comparison
can be made Equal, Not equal, Less, Less or equal,
Greater or Greater or equal.
Layer is empty
Test if a layer currently has zero instances on it. This
counts any objects anywhere at all on the layer, so
even one instance far outside the viewport will make
this condition false.
Layer is visible
Test if a layer is currently visible or not.
On canvas snapshot
Revision 3 Page 732/765
Triggered after the Snapshot canvas system action,
when the snapshot is ready. It can then be accessed
with the CanvasSnapshot system expression.
Loops
Loops can be stopped with the Stop Loop system
action.
For
Repeat the event a number of times, using an index
variable over a range of values. The index can be
retrieved with the LoopIndex system expression and
passing the name of the loop.
For Each
For Each (ordered)
Repeat the event once per picked instance. This only
repeats for instances that have been picked by prior
conditions. See how events work for more
information on picking. For Each is commonly mis-
used or used redundantly - actions already apply for
each instance picked by conditions, so it often is
simply not needed. However, if you fully understand
how the event system works, it can be used to force
the event to apply once per instance where the event
system would not normally do that. The 'ordered'
variant allows the order that the instances are iterated
in to be defined by an expression. For example,
ordering by Sprite.Y ascending will iterate the top
instances on the screen first, moving downwards.
Revision 3 Page 733/765
Repeat
Simply repeat the event a given number of times.
This tests any conditions following it on every repeat,
and if those conditions are met also runs the actions
and any sub-events on every repeat.
While
Repeat the event until one of the other conditions in
the event becomes false or a Stop loop action is
used. Be careful not to create infinite loops which will
cause the game to hang.
Pick instances
Pick all
Reset the picked objects back to all of them.
Subsequent conditions will pick from all instances
again instead of filtering from only those meeting all
the conditions so far. See How events work for more
information on how instances are picked in events.
Useful in subevents to start affecting different
instances again.
Pick by comparison
Pick the individual instances of an object type that
meet a comparison. For example, it is possible to pick
all instances where Object.X [] 2 is less than
Object.Y + 100, which is not possible with either the
Compare X or Compare Y* conditions.
Special conditions
Else
Run if the previous event did not run. Note that this
condition does not pick any objects: if it follows an
event that picks objects, in the Else event all
instances revert to picked again. Else can only follow
normal (non-triggered) events. It can also follow
another Else event with other conditions to make an
"if - else if - else" chain.
Is in preview
True when running the project from a preview in
Construct 2, and false when running after being
exported. Useful to add debug or diagnostic features
for previewing only.
Is on mobile device
Tries to detect whether the current device viewing the
project is a mobile (e.g. phone or tablet). It is difficult
to accurately detect this so detection may not be
perfect: there may be some mobile systems for which
Is on mobile is not true, and (although less likely)
Revision 3 Page 736/765
desktop systems for which Is on mobile returns true.
The condition always returns true when packaged via
the PhoneGap/Intel XDK/CocoonJS containers, and
always returns true for iOS, Android, Blackberry 10,
Windows Phone and Tizen based devices. Beyond
that Construct 2 will test a few other common mobile
manufacturers. Otherwise, it will return true if the
current system is not a desktop system, since there
are relatively few desktop OSs; the desktop systems
it checks for are Windows, Linux, OS 9, OS X,
Solaris and BSD.
Is on platform
Test if currently running on a given platform, such as
Android or as a Windows 8 app. Note it's possible
multiple options can be true simultaneously. For
example, if running in a browser on Android, both Is
on platform Android and Is on platform HTML5
website will be true.
On load failed
Triggered after the Load system action fails to
complete, usually because the slot has not been
saved to yet. For more information, see How to make
savegames.
On save complete
Triggered after the Save system action successfully
completes. For more information, see How to make
savegames.
On save failed
Triggered if the Save system action fails to complete.
This can occur if the browser has reached the limit of
its storage quota, or the user has withdrawn
permission for the page or app to write to storage.
Time
Compare time
Compare the time, in seconds, since the game
began. For example, events can be set up to run
when the time reaches (equals) 10 seconds.
Every X seconds
Run the event regularly at a given time interval in
seconds. This can also be used beneath other
conditions to only run the event at a given time
interval while the other conditions are true, e.g.
"Player is holding spacebar AND every 0.5 seconds:
fire laser".
Display
Set canvas size
Set the size of the canvas area in the page, if
appearing inline to the page (i.e. a fullscreen mode is
not used). If a fullscreen mode is in use, this
effectively changes the size of the Window size
project property, which adjusts the size of the
viewport.
Snapshot canvas
Take a screenshot of the current display. This
triggers On canvas snapshot when the snapshot is
Revision 3 Page 740/765
ready, and the resulting image can be accessed with
the CanvasSnapshot system expression. This can
then be loaded in to a sprite or tiled background, sent
to a server, or opened with the Browser object in a
new tab.
General
Create object
Create a new instance of an object type on a layer at
a given position. If a Family is chosen, a random
object type from the family is picked, and an instance
created for that.
Go to layout
Go to layout (by name)
Switch to another layout in the project. Note that
global variables keep their current value - they are
not reset. To reset them use the system action Reset
global variables.
Go to next/previous layout
Switch to the next or previous layout in the project.
The order as they appear in the Project Bar is used,
where layouts at the top are first and layouts at the
bottom are last. If on the first layout, trying to go to
the previous layout does nothing, and if on the last
layout, trying to go to the next layout does nothing.
Note that global variables keep their current value -
they are not reset. To reset them use the system
action Reset global variables.
Revision 3 Page 741/765
Restart layout
Restart the current layout. Note that unlike Go to
layout, this action resets all event groups to their
initial activation state. Global variables keep their
current value - they are not reset. To reset them use
the system action Reset global variables.
Sort Z order
Sort the Z order of instances of a given object
according to an instance variable. This effectively
removes all instances from their Z order, sorts them,
then inserts the sorted sequence back in to the holes
left behind. This means if the instances are spread
across a range of layers, they will be sorted in the
same Z order locations, maintaining the same order
relative to other instances on those layers. Note this
action is much faster than using an ordered For each
with an action like Send to front/back, so this action
should be the preferred way to sort the Z order of
large numbers of instances.
Stop loop
Stop a Repeat, For or For each loop currently
running. These loops are system conditions. The rest
of the event's actions and subevents will still
Revision 3 Page 742/765
complete, but the loop will not run any further after
that.
Save
Save the state of the game to a save slot. When
done, triggers On save complete. For more
information see How to make savegames.
Scrolling
To scroll, the size of the layout must be bigger than the
size of the window, or the layout's Unbounded scrolling
property must be set to Yes. Otherwise there is nowhere
to scroll to and scrolling will have no effect.
Scroll to object
Center the view on a given object. This scrolls all
layers taking in to account their parallax property.
Scroll to position
Scroll to X
Scroll to Y
Set the X and Y positions to center the view on. This
scrolls all layers taking in to account their parallax
property.
Time
Revision 3 Page 747/765
Set time scale
Change the rate time passes at in the game. Useful
for slow-motion or pausing effects. See the tutorial on
Delta-time and framerate independence for more
information.
Signal
Resume any events paused with a Wait for signal
action with the given tag.
Revision 3 Page 748/765
Wait
Wait a number of seconds before continuing on to
the next action or sub-events. Other events continue
to run in the meantime. See also the tutorial on How
to use the System 'Wait' actions.
Display
OriginalWindowWidth
OriginalWindowHeight
Get the original values of the Window size project
property.
WindowWidth
WindowHeight
Get the size of the canvas being displayed in device
Revision 3 Page 750/765
pixels. Note this is not the same as the viewport; see
the ViewportLeft/Top/Right/Bottom expressions. See
also Supporting multiple screen sizes. #Layers# In
expressions where a layer is required, either its name
(as a string) or index (as a number, zero-based) can
be entered.
CanvasToLayerX(layer, x, y)
CanvasToLayerY(layer, x, y)
Calculate the layout co-ordinates underneath a
position in canvas co-ordinates for a given layer.
LayerToCanvasX(layer, x, y)
LayerToCanvasY(layer, x, y)
Calculate the canvas co-ordinates above a position in
layout co-ordinates for a given layer.
LayerAngle(layer)
Get the angle, in degrees, of a layer.
LayerIndex(layer)
Get the zero-based index of a layer from its name.
LayerOpacity(layer)
Get the opacity (or semitransparency) of a layer, from
0 (transparent) to 100 (opaque).
LayerParallaxX(layer)
LayerParallaxY(layer)
Get the current parallax X and Y components of a
layer.
Revision 3 Page 751/765
LayerScale(layer)
Get the current scale of the layer, not including the
overall layout scale.
LayerScaleRate(layer)
Get the current scale rate of the layer, which defines
how quickly it scales (if at all).
ViewportBottom(layer)
ViewportLeft(layer)
ViewportRight(layer)
ViewportTop(layer)
Return the viewport boundaries in layout co-ordinates
of a given layer. Not all layers have the same
viewport if they are parallaxed, scaled or rotated
separately.
Layout
CanvasSnapshot
Contains the resulting image from a Snapshot
canvas action after On canvas snapshot has run.
(Note this expression is not available immediately
after the Snapshot canvas action - you can only use
it after On canvas snapshot triggers.) The expression
returns a data URI of the image file. This can be
loaded in to a Sprite or Tiled Background object via
Load image from URL, sent to a server or stored
locally, or opened with the Browser object in a new
tab to save to disk.
Revision 3 Page 752/765
LayoutAngle
Get the angle, in degrees, of the current layout. This
does not include the rotation of individual layers.
LayoutScale
Get the current scale of the entire layout set by the
Set layout scale action. This does not include the
scaling of individual layers.
LayoutWidth
LayoutHeight
Get the size of the current layout in pixels.
LayoutName
Get the name of the current layout.
scrollx
scrolly
Get the current position the view is centered on.
Math
These expressions are simply ordinary math functions
like you find on calculators. However, note that all
functions using an angle take it in degrees, not radians.
Angles start with 0 degrees facing right and increment
clockwise.
sin(x)
, cos(x) , tan(x) , asin(x) , acos(x) , atan(x)
Revision 3 Page 753/765
Trigonometric functions using angles in degrees.
abs(x)
Absolute value of x e.g. abs(-5) = 5
anglelerp(a, b, x)
Linearly interpolate the angle a to b by x. Unlike the
standard lerp, this takes in to account the cyclical
nature of angles.
anglediff(a1, a2)
Return the smallest difference between two angles
ceil(x)
Round up x e.g. ceil(5.1) = 6
cosp(a, b, x)
Cosine interpolation of a to b by x. Calculates (a + b
+ (a - b) [] cos(x [] 180°)) / 2.
cubic(a, b, c, d, x)
Cubic interpolation through a, b, c and d by x.
Revision 3 Page 754/765
Calculates lerp(qarp(a, b, c, x), qarp(b, c, d, x), x).
exp(x)
Calculate e^x
floor(x)
Round down x e.g. floor(5.9) = 5
infinity
A floating point number value representing infinity.
lerp(a, b, x)
Linear interpolation of a to b by x. Calculates a + x [*]
(b - a).
unlerp(a, b, y)
Reverse linear interpolation: if lerp(a, b, x) = y, then
unlerp(a, b, y) = x. Calculates (y - a) / (b - a).
ln(x)
Log to base e of x.
log10(x)
Log to base 10 of x.
max(a, b [, c...])
, min(a, b [, c...]) Calculate maximum or minimum of
Revision 3 Page 755/765
the given numbers. Any number of parameters can
be used as long as there are at least two.
pi
The mathematical constant pi (3.14159...)
qarp(a, b, c, x)
Quadratic interpolation through a, b and c by x.
Calculates lerp(lerp(a, b, x), lerp(b, c, x), x).
round(x)
Round x to the nearest whole number e.g. round(5.6)
=6
sqrt(x)
Calculate square root of x e.g. sqrt(25) = 5
getbit(x, n)
Get the nth bit of x represented as a 32-bit integer.
For example getbit(7, 0) will get the least significant
bit of the number 7 when represented as a 32-bit
integer. Returns either 0 or 1.
setbit(x, n, b)
Set the nth bit of x represented as a 32-bit integer to
b (either 0 or 1). The resulting 32-bit integer is
returned.
togglebit(x, n)
Toggle the nth bit of x represented as a 32-bit integer.
Revision 3 Page 756/765
If that bit is 0, it is set to 1; if it is 1, it is set to 0. The
resulting 32-bit integer is returned.
System
ImageMemoryUsage
Returns the estimated total memory usage, in
megabytes, of all the currently-loaded images. Only
supported in the WebGL renderer; if canvas2D
rendering is in use, the expression always returns 0.
Note image memory is sometimes also referred to as
"VRAM", but this is not strictly correct since not all
devices have video-specific memory. Also remember
this expression does not include the memory use of
sounds, code, or other non-image resources.
loadingprogress
Return the current load progress on a loader layout,
or the current update progress while the Browser
object's Is downloading update condition is true. The
progress is returned as a number from 0 to 1, e.g. 0.5
for half complete. For more information, see the
Revision 3 Page 757/765
tutorials how to make a custom loading screen and
offline games in Construct 2.
loopindex
Get the index (number of repeats so far) in any
currently running loop.
loopindex(name)
Get the index (number of repeats so far) of the loop
with the given name. Useful for getting indices in
nested loops.
objectcount
The total number of objects currently created.
projectname
Return the name of the project as it appears in
Project Properties.
projectversion
Return the version entered in to Project Properties.
Note that this is always returned as a string, not a
number.
renderer
The name of the renderer used to draw the game,
currently either canvas2d or webgl. See Technology
for more information on canvas renderers.
rendererDetail
The name of the graphics hardware in use to draw
Revision 3 Page 758/765
the game, such as "NVIDIA GeForce GTX 660" or
"Adreno 330". This is only available in WebGL mode
in certain browsers and platforms; unsupported
browsers/systems will return "(unavailable)". Projects
should not rely on this string having any exact
contents, but it can be useful to diagnose which GPU
is in use in dual-GPU systems, or to look for
keywords and apply default graphics settings based
on the type of hardware.
Text
find(src, text)
findCase(src, text)
Find the first index within src that text occurs, else
returns -1. find is case-insensitive, and findCase is
case-sensitive.
left(text, count)
Return the first count characters of text.
len(text)
Return the number of characters in text.
lowercase(text)
Convert the given text to all lowercase.
right(text, count)
Return the last count characters of text.
tokencount(src, separator)
Count how many tokens occur in src using
separator. For example,
tokencount("apples|oranges|bananas", "|") returns
3.
trim(src)
Return src with all whitespace (spaces, tabs etc.)
removed from the beginning and end of the string.
uppercase(text)
Convert the given text to all uppercase.
URLEncode(str)
URLDecode(str)
Convert to and from a string in a format suitable for
including in a URL or POST data.
zeropad(number, digits)
Revision 3 Page 761/765
Pad number out to a certain number of digits by
adding zeroes in front of the number, then returning
the result as a string. For example, zeropad(45, 5)
returns the string "00045".
Time
CPUUtilisation
The percentage of the last second that was spent in
the application logic. This is for advanced users to
make performance measurements. Note on
hardware-accelerated devices the rendering happens
on the separate GPU and therefore this
measurement cannot tell you anything about how fast
or slow the rendering is; for that fps is a better
measure. Also note this measurement is based on
timers so should be treated as an approximation, and
it only measures the main Javascript thread time.
dt
Delta-time in seconds. See Delta-time and framerate
independence.
fps
The current frames per second (FPS) rate, which is
how many times the screen is being drawn every
second. Most computers run at 60 fps if they are fast
enough.
tickcount
Revision 3 Page 762/765
The number of ticks that have run since the game
started.
time
The number of seconds since the game started,
taking in to account the time scale.
timescale
The current time scale.
wallclocktime
The number of seconds since the game started, not
taking in to account the time scale (i.e. the real-world
time).
Values
choose(a, b [, c...])
Choose one of the given parameters at random. E.g.
choose(1, 3, 9, 20) randomly picks one of the four
numbers and returns that. This also works with
strings, e.g. choose("Hello", "Hi") returns either Hello
or Hi. Any number of parameters can be used as
long as there are at least two.
float(x)
Revision 3 Page 763/765
Convert the integer or text x to a float (fractional
number). If x is text, non-numeric characters are
allowed after the number, but not before. For example
float("3.1xx") returns 3.1, but float("xx3.1") returns 0.
int(x)
Convert the float or text x to an integer (whole
number). If x is text, non-numeric characters are
allowed after the number, but not before. For example
int("33xx") returns 33, but int("xx33") returns 0.
random(x)
Generate a random float from 0 to x, not including x.
E.g. random(4) can generate 0, 2.5, 3.29293, but not
4. Use floor(random(4)) to generate just the whole
numbers 0, 1, 2, 3.
random(a, b)
Generate a random float between a and b, including
a but not including b.
rgb(r, g, b)
Generate a single number containing a color in RGB
format. This is useful for conditions or actions taking
a color parameter.
str(x)
Convert the integer or float x to a string. Generally
not necessary since strings can be built using the &
operator, e.g. "Your score is " & score
Revision 3 Page 764/765
Revision 3 Page 765/765