Technology

Construct 2 makes HTML5 games. These run online in a web browser on a wide variety of different devices and operating systems, including on mobile devices like phones and tablets, ensuring your game is accessible to as many people as possible. This section is a summary of the technology involved. It is probably of more interest to technically-minded people and can be skipped if you are more interested in the details of how to use Construct 2.

Despite the fact that Construct 2 games can be ported to a variety of different platforms even as "native" apps, the underlying technology is still a HTML5-based engine.

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 to program web pages, and this is also used to power Construct 2 games.

Of particular interest in HTML5 is the newly introduced <canvas> tag. This creates a rectangular surface in a HTML web page where any images or content can be drawn. This makes it ideal for games. All Construct 2 games use the HTML5 canvas to display the game.

HTML5 is comparable to Adobe's Flash technology which dominated the internet for gaming prior to 2011. HTML5 differs in being an industry-agreed standard, rather than a product controlled by a single company like Adobe. Flash also runs as a browser plugin, which must be separately downloaded and installed, whereas HTML5 is built in to the browser. This also means HTML5 games can run on devices where there is no Flash support, such as iPhones and iPads. Given its advantages, HTML5 will eventually replace Flash on the web.

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.

Javascript is not Java. These are two unrelated programming languages which simply happen to have a similar name. Java applets are another technology which can run in a web page, but it is a totally different technology to Javascript. Try not to get confused between the two: games made in Construct 2 do not need or use Java to run.

Modern browsers compile javascript to native machine code (or CPU instructions). This ensures that web pages (including games) using javascript run as quickly and efficiently as possible.

Javascript is a garbage-collected language, which makes games vulnerable to pauses or stuttering due to garbage collection. Construct 2's game engine is optimised to create minimum garbage, recycling objects wherever possible. Even entire object instances are recycled if an object is destroyed and later re-created. This helps improve performance and ensure the game runs as smoothly as possible.

Plugin and Behavior SDK

Javascript programmers can extend Construct 2 with their own plugins and behaviors. See the Javascript SDK documentation for more information.

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 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".

Obfuscation and minification

The javascript code to your game is minified and obfuscated with Google's Closure Compiler. This reduces the download size and makes it extremely difficult for anybody to reverse engineer your game.

The game images are compressed in PNG format. They are also further compressed when exporting to ensure the download is as small as possible. For more information, see this blog post on Image compression in Construct 2.

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.

Offline support

Despite the fact HTML5 games run in a web browser, Construct 2 games use the HTML5 AppCache 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 AppCache 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. The most important point is your server must be set up to serve .appcache files with the MIME type text/cache-manifest.

Tags: