phaser/wip/core/Plugin.js

123 lines
3.3 KiB
JavaScript
Raw Normal View History

/**
2013-10-01 12:54:29 +00:00
* @author Richard Davey <rich@photonstorm.com>
2016-04-04 21:15:01 +00:00
* @copyright 2016 Photon Storm Ltd.
2013-10-01 12:54:29 +00:00
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
2014-03-23 07:59:28 +00:00
/**
2013-10-01 12:54:29 +00:00
* This is a base Plugin template to use for any Phaser plugin development.
2014-03-23 07:59:28 +00:00
*
2013-10-01 12:54:29 +00:00
* @class Phaser.Plugin
* @constructor
* @param {Phaser.Game} game - A reference to the currently running game.
* @param {any} parent - The object that owns this plugin, usually Phaser.PluginManager.
*/
Phaser.Plugin = function (game, parent) {
if (parent === undefined) { parent = null; }
2013-10-02 10:22:20 +00:00
/**
* @property {Phaser.Game} game - A reference to the currently running game.
*/
this.game = game;
2014-03-23 07:59:28 +00:00
2013-10-01 12:54:29 +00:00
/**
* @property {any} parent - The parent of this plugin. If added to the PluginManager the parent will be set to that, otherwise it will be null.
*/
this.parent = parent;
2014-03-23 07:59:28 +00:00
2013-10-01 12:54:29 +00:00
/**
* @property {boolean} active - A Plugin with active=true has its preUpdate and update methods called by the parent, otherwise they are skipped.
* @default
*/
this.active = false;
2014-03-23 07:59:28 +00:00
2013-10-01 12:54:29 +00:00
/**
* @property {boolean} visible - A Plugin with visible=true has its render and postRender methods called by the parent, otherwise they are skipped.
* @default
*/
this.visible = false;
2014-03-23 07:59:28 +00:00
2013-10-01 12:54:29 +00:00
/**
* @property {boolean} hasPreUpdate - A flag to indicate if this plugin has a preUpdate method.
* @default
*/
this.hasPreUpdate = false;
2014-03-23 07:59:28 +00:00
2013-10-01 12:54:29 +00:00
/**
* @property {boolean} hasUpdate - A flag to indicate if this plugin has an update method.
* @default
*/
this.hasUpdate = false;
/**
* @property {boolean} hasPostUpdate - A flag to indicate if this plugin has a postUpdate method.
* @default
*/
this.hasPostUpdate = false;
2014-03-23 07:59:28 +00:00
2013-10-01 12:54:29 +00:00
/**
* @property {boolean} hasRender - A flag to indicate if this plugin has a render method.
* @default
*/
this.hasRender = false;
2014-03-23 07:59:28 +00:00
2013-10-01 12:54:29 +00:00
/**
* @property {boolean} hasPostRender - A flag to indicate if this plugin has a postRender method.
* @default
*/
this.hasPostRender = false;
};
Phaser.Plugin.prototype = {
/**
2013-10-02 10:22:20 +00:00
* Pre-update is called at the very start of the update cycle, before any other subsystems have been updated (including Physics).
* It is only called if active is set to true.
2013-10-02 10:22:20 +00:00
* @method Phaser.Plugin#preUpdate
*/
preUpdate: function () {
},
/**
* Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render.
* It is only called if active is set to true.
2013-10-02 10:22:20 +00:00
* @method Phaser.Plugin#update
*/
update: function () {
},
/**
* Render is called right after the Game Renderer completes, but before the State.render.
* It is only called if visible is set to true.
2013-10-02 10:22:20 +00:00
* @method Phaser.Plugin#render
*/
render: function () {
},
/**
* Post-render is called after the Game Renderer and State.render have run.
* It is only called if visible is set to true.
2013-10-02 10:22:20 +00:00
* @method Phaser.Plugin#postRender
*/
postRender: function () {
},
/**
* Clear down this Plugin and null out references
2013-10-02 10:22:20 +00:00
* @method Phaser.Plugin#destroy
*/
destroy: function () {
this.game = null;
this.parent = null;
this.active = false;
this.visible = false;
2014-03-23 07:59:28 +00:00
}
};
Phaser.Plugin.prototype.constructor = Phaser.Plugin;