Enchant.js Guide

by Patrick Casao, Cal Poly

11 Plugins

You can access the plugins here, in the plugins folder.

01 A Word on Plugins
02 How to Use Plugins

11.01 - A Word on Plugins

Aside from the main library, there are several plugins that you may use with enchant.js. These plugins provide additional functionality, such as access to graphics library of WebGL or the physics engine of box2d.

In order to use any of the plugins compatible with enchant.js, you need to include these lines between script tags in the html file you’re using to load your enchant.js project:

script type = “text/javascript” src=”enchant.js”
script type = “text/javascript” src=”nineleap.enchant.js”
script type = “text/javascript” src=”twitter.enchant.js”
These will include the enchant.js library, the nineleap plugin, and the twitter plugin. If these scripts aren’t included and you try to use plugins, you may receive an error that looks like:

superclass is not defined

11.02 - How to Use Plugins

If you’ve already set up your HTML file as described in the previous subsection, all you need to do in order to use one is include a plugin using the script tags. This example assumes that your plugins are in some folder named plugins that’s in the same directory as your HTML file:

script type=”text/javascript” src=”plugins/SOME_PLUGIN.js”
Make sure that you include dependent plugins and libraries.

In the next few sections, I’m going to demonstrate the use of the plugins:
You can read about more plugins here.
You can access the documentation here.