2013-08-29 02:52:59 +00:00
|
|
|
/**
|
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.
|
2014-11-30 11:10:52 +00:00
|
|
|
* @param {any} parent - The object that owns this plugin, usually Phaser.PluginManager.
|
2013-08-29 02:52:59 +00:00
|
|
|
*/
|
|
|
|
Phaser.Plugin = function (game, parent) {
|
|
|
|
|
2015-07-22 09:37:15 +00:00
|
|
|
if (parent === undefined) { parent = null; }
|
2013-10-02 10:22:20 +00:00
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
/**
|
|
|
|
* @property {Phaser.Game} game - A reference to the currently running game.
|
|
|
|
*/
|
2013-08-29 02:52:59 +00:00
|
|
|
this.game = game;
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2014-11-30 11:10:52 +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.
|
2013-11-25 03:13:04 +00:00
|
|
|
*/
|
2013-08-29 02:52:59 +00:00
|
|
|
this.parent = parent;
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-11-25 03:13:04 +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
|
|
|
|
*/
|
2013-08-29 02:52:59 +00:00
|
|
|
this.active = false;
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-11-25 03:13:04 +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
|
|
|
|
*/
|
2013-08-29 02:52:59 +00:00
|
|
|
this.visible = false;
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {boolean} hasPreUpdate - A flag to indicate if this plugin has a preUpdate method.
|
|
|
|
* @default
|
|
|
|
*/
|
2013-08-29 02:52:59 +00:00
|
|
|
this.hasPreUpdate = false;
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {boolean} hasUpdate - A flag to indicate if this plugin has an update method.
|
|
|
|
* @default
|
|
|
|
*/
|
2013-08-29 02:52:59 +00:00
|
|
|
this.hasUpdate = false;
|
2013-11-02 06:04:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {boolean} hasRender - A flag to indicate if this plugin has a render method.
|
|
|
|
* @default
|
|
|
|
*/
|
2013-08-29 02:52:59 +00:00
|
|
|
this.hasRender = false;
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2013-10-01 12:54:29 +00:00
|
|
|
/**
|
2013-11-25 03:13:04 +00:00
|
|
|
* @property {boolean} hasPostRender - A flag to indicate if this plugin has a postRender method.
|
|
|
|
* @default
|
|
|
|
*/
|
2013-08-29 02:52:59 +00:00
|
|
|
this.hasPostRender = false;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2013-08-29 06:06:16 +00:00
|
|
|
Phaser.Plugin.prototype = {
|
2013-08-29 02:52:59 +00:00
|
|
|
|
|
|
|
/**
|
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).
|
2013-08-29 02:52:59 +00:00
|
|
|
* It is only called if active is set to true.
|
2013-10-02 10:22:20 +00:00
|
|
|
* @method Phaser.Plugin#preUpdate
|
2013-08-29 02:52:59 +00:00
|
|
|
*/
|
|
|
|
preUpdate: function () {
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-09-11 16:32:53 +00:00
|
|
|
* Update is called after all the core subsystems (Input, Tweens, Sound, etc) and the State have updated, but before the render.
|
2013-08-29 02:52:59 +00:00
|
|
|
* It is only called if active is set to true.
|
2013-10-02 10:22:20 +00:00
|
|
|
* @method Phaser.Plugin#update
|
2013-08-29 02:52:59 +00:00
|
|
|
*/
|
|
|
|
update: function () {
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-09-11 16:32:53 +00:00
|
|
|
* Render is called right after the Game Renderer completes, but before the State.render.
|
2013-08-29 02:52:59 +00:00
|
|
|
* It is only called if visible is set to true.
|
2013-10-02 10:22:20 +00:00
|
|
|
* @method Phaser.Plugin#render
|
2013-08-29 02:52:59 +00:00
|
|
|
*/
|
|
|
|
render: function () {
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-09-11 16:32:53 +00:00
|
|
|
* Post-render is called after the Game Renderer and State.render have run.
|
2013-08-29 02:52:59 +00:00
|
|
|
* It is only called if visible is set to true.
|
2013-10-02 10:22:20 +00:00
|
|
|
* @method Phaser.Plugin#postRender
|
2013-08-29 02:52:59 +00:00
|
|
|
*/
|
|
|
|
postRender: function () {
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear down this Plugin and null out references
|
2013-10-02 10:22:20 +00:00
|
|
|
* @method Phaser.Plugin#destroy
|
2013-08-29 02:52:59 +00:00
|
|
|
*/
|
|
|
|
destroy: function () {
|
|
|
|
|
|
|
|
this.game = null;
|
|
|
|
this.parent = null;
|
|
|
|
this.active = false;
|
|
|
|
this.visible = false;
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2013-08-29 02:52:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
2013-12-30 16:54:00 +00:00
|
|
|
|
|
|
|
Phaser.Plugin.prototype.constructor = Phaser.Plugin;
|