plugin Class
Provides methods for patching core functions, and registering plugins.
Methods
patch
(
-
obj
-
name
-
fn
Patches a core function with a new one. The function you override with has a special property
called this._super
which is a reference to the function you are overriding.
Parameters:
-
obj
ObjectThe object with the method to override
-
name
StringThe name of the method to override
-
fn
FunctionThe function to override with
Example:
//For example, to patch the gf.Sprite.prototype.isActiveAnimation function:
gf.plugin.patch(gf.Sprite, 'isActiveAnimation', function() {
//display a console message
console.log('checking animation!');
//call the original function
this._super();
});
register
(
-
plugin
-
name
Registers a plugin into the gf namespace.
Parameters:
-
plugin
ObjectThe object to place in the namespace
-
name
StringThe name of the plugin to use as the key
Example:
//For example, to register a new plugin:
gf.plugin.register(MyPluginObject, 'MyPluginName');
var plg = new gf.MyPluginName();