Scripting overview

Construct supports writing JavaScript code in the place of actions and events, as well as in separate JavaScript files. This is a great way to learn to code, as well as taking advantage of the full power of the JavaScript programming language in your projects. Construct also supports TypeScript, an extension of JavaScript that adds static type features. This section of the manual covers using JavaScript code in Construct, as well as information about using TypeScript.

JavaScript is not Java

Note Java is a completely different programming language to JavaScript. This is a common point of confusion. Try not to get the two mixed up. For example if you search the web for help on JavaScript, be sure to specifically search for JavaScript and not Java, otherwise you will get results for the wrong programming language!

Terminology

JavaScript is often shortened to JS and normally uses files with the extension .js. The terms script and code refer to the same thing: the programming code that you or someone else has written. Similarly scripting, coding and programming are used interchangeably, and all refer to the process of writing code in a programming language. In the context of Construct this always refers to JavaScript code, since it's the only programming language it uses.

Quick start guide

If you already know JavaScript, check out the Construct for JavaScript developers quick start guide for a summary of what you might need to know when working in Construct. If you'd also prefer to use an external code editor like VS Code, see Using an external editor.

Introductory video

For a video introduction to using JavaScript in Construct, see the video below.

Subscribe to Construct videos now

Learning JavaScript

If you're interested in learning JavaScript from scratch using Construct, see our 13-part tutorial series Learn JavaScript in Construct.

JavaScript is one of the most popular languages in the world, and is widely used in the technology industry, especially in web development. As a result there are many more materials available across the web for teaching the JavaScript language. The tutorial series linked to above includes lots of links towards the end where you can continue learning more about JavaScript.

This manual section focuses on the unique details of using JavaScript within Construct. We recommend the MDN web docs as a good reference to use for the JavaScript language itself. This manual links to it when referring to specific parts of the JavaScript programming language so you can learn more about it.

TypeScript

Construct also supports writing code in TypeScript, which is an extension of JavaScript that adds static types. This can provide improved tooling such as better autocomplete. See the guide Using TypeScript in Construct to learn more.

Examples

See the Scripting category of the Example Browser for a variety of example projects making use of JavaScript coding in Construct. These cover everything from simple beginner examples to sophisticated fully-coded games.

The reference section of the manual also includes some code samples in places, with snippets demonstrating how to use specific features. These will usually need to be pasted in to a project with appropriately named objects and behaviors to work correctly, or otherwise edited as necessary for use in your own projects.

Construct 3 Manual 2024-07-19