API Docs for: v0.1.0
Show:

plugin Class

Extends Object
Defined in: src\plugin.js:2

Provides methods for patching core functions, and registering plugins.

Item Index

Methods

Methods

patch

(
  • obj
  • name
  • fn
)

Defined in src\plugin.js:9

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 Object

    The object with the method to override

  • name String

    The name of the method to override

  • fn Function

    The 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
)

Defined in src\plugin.js:55

Registers a plugin into the gf namespace.

Parameters:

  • plugin Object

    The object to place in the namespace

  • name String

    The 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();