plugin

namespace plugin

Summary


Properties from plugin

Public Properties


cache plugin.js:9
cache

Contains all registered plugins.

Public Methods


get plugin.js:150
get(classType: object | string) → {BasePlugin}

returns the the plugin instance with the specified class type or registered name

Parameters:
Name Type Description
classType object | string

the Class Object or registered name of the plugin to retreive

Returns:
Type Description
BasePlugin

a plugin instance or undefined

patch plugin.js:63
patch(proto: object, name: string, fn: Function) → {}

patch a melonJS function

// redefine the me.game.update function with a new one
me.plugin.patch(me.game, "update", function () {
  // display something in the console
  console.log("duh");
  // call the original me.game.update function
  this._patched();
});
Parameters:
Name Type Description
proto object

target object

name string

target function

fn Function

replacement function

register plugin.js:106
register(plugin: BasePlugin, name: string, args: unknown) → {}

Register a plugin.

// register a new plugin
me.plugin.register(TestPlugin, "testPlugin");
// the `testPlugin` class instance can also be accessed through me.plugin.cache
me.plugin.cache.testPlugin.myfunction ();
Parameters:
Name Type Attributes Default Description
plugin BasePlugin

Plugin object to instantiate and register

name string

<optional>

plugin.constructor.name

a unique name for this plugin

args unknown

<optional>

all extra parameters will be passed to the plugin constructor


Powered by webdoc!