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. This section can be skipped if you are happy to know your games simply run in a web browser.
Web Browsers
A
browser is the program that loads and displays web pages on your computer. Popular web browsers include:
Internet Explorer (only version 9 or newer works with HTML5)
Mozilla FirefoxGoogle ChromeOperaMacs also commonly use
Safari.
Some of these browsers are also available for mobiles and tablets.
HTML5
HTML stands for
Hyper
Text
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 the minimum garbage possible, 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. WebGL is several times faster than the 2D context and has more features, but has slightly higher hardware requirements (you need an OpenGL 2.0 compatible graphics card and up-to-date graphics drivers). Most browsers support WebGL, but Internet Explorer does not. 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. If WebGL is not supported by a user's computer, 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.
Since Internet Explorer does not support WebGL, if you're using it you may want to switch to a different browser which does support it like Firefox or Chrome. You may also wish to advise the people who play your game to do the same.
WebGL may not be supported on a computer even if it is enabled. In this case the 2D context will be used instead. 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 in Google Chrome for reliable low-latency playback of sound effects. In other browsers 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 else the offline support
will not work and will cause you to waste a lot of bandwidth.