New this build: a new template/example start dialog, and built-in Function object, allowing you to call events like functions.
The new template/example dialog replaces the old New Project dialog. Now you can choose from over 70 templates or examples right from Construct 2. These include some brand new "game templates" such as a basic platformer setup, some simple physics games templates, and so on, designed to help beginners get to grips with Construct 2 quickly.
Then there's the new Function object. If you are unfamiliar with functions, it means you can re-use a block of events in many places in your project. For example you could have a function "CreateEnemy". This could create a sprite and some other associated objects, initialise variables, play a sound effect, and perhaps update the score or alert the player. If this is 10 actions, rather than repeating the same 10 actions in multiple places, you can just call the "CreateEnemy" function. This makes it easier to manage large projects where you want to re-use a set of actions or events in multiple places. It's also useful in education uses, since calling functions in events is analogous to calling functions in real programming languages.
The Function object supports a new interface in the editor for adding as many parameters as you need:
This allows multiple parameters to be added easily, without having to use multiple "add parameter" actions. The Function object also supports:
- Functions calling other functions
- Functions calling themselves (recursion)
- Returning values from functions
- Calling functions from expressions (which also returns the return value)
- Browser console logging in preview mode if functions used incorrectly or suspiciously, such as calling nonexistant functions or accessing parameters that aren't provided
- Performance tuned for large projects
The last point is interesting: typically when a trigger is run, Construct 2 has to check every single trigger of that type in the project. For calling functions, this could mean checking triggers for unrelated functions every time a function is called, possibly causing a slowdown for large projects. To get around that, we specifically added an optimisation for the Function object. Calling a function will now directly run only the exact matching function triggers, and it will not even check 'On function' triggers for other function names. This means you can continue to use functions even in very large projects using functions heavily, remaining confident that functions are still triggering efficiently.