Each plugin has its own folder. Plugins consist of four files:
- common.js - this is prepended to both edittime.js and runtime.js in case you have code common to both.
- edittime.js - defines the plugin for the editor, including all its actions, conditions and expressions.
- runtime.js - defines the plugin functionality in the browser.
- PluginIcon.ico - the editor loads this icon to represent the plugin.
A template for both a plugin and behavior can be downloaded here. You can copy these to a folder in the above directories to provide a skeleton starting point for your plugin or behavior.
Plugins work identically in the 32-bit and 64-bit versions of Construct 2.
All the "built-in" plugins and behaviors are also written this way. It would be useful to read their scripts - also in the above directories - to see how their features are implemented. You can learn a lot from this.
All the scripts for the entire javascript runtime are also located in <install path>\exporters\html5
. They are perfectly readable and commented (not minified). This is a great way to learn even more, but may make for some heavy reading. You may find these three scripts particularly relevant, though:
- common_prelude.js - prepended to both edittime scripts and runtime scripts.
- edittime_prelude.js - prepended only to edittime scripts.
- preview_prelude.js - prepended only to runtime scripts.
Remember that javascript has no way of limiting access to objects. This means you can alter any part of the runtime at any time. You should assume this is a bad idea (with undefined consequences) unless the object properties have been explicitly documented with valid ways of accessing the property. The runtime is complex, and any undocumented changes you make may break projects in subtle ways or have other unintended consequences. Keep the reference handy!
Good luck!
Developing your own plugins and behaviors is relatively straightforward and can be fun! The following guide pages describe plugin development in more detail. If you have any questions about the SDK feel free to ask on the forum, but please remember we ask that you look to other resources for questions on the javascript language itself.