2023-02-13 21:21:18 +00:00
|
|
|
/**
|
2024-02-19 17:12:18 +00:00
|
|
|
* @author Richard Davey <rich@phaser.io>
|
|
|
|
* @copyright 2013-2024 Phaser Studio Inc.
|
2023-02-13 21:21:18 +00:00
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
|
|
|
*/
|
|
|
|
|
2023-02-16 23:49:14 +00:00
|
|
|
var Class = require('../utils/Class');
|
2023-02-13 21:21:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @classdesc
|
2023-03-21 17:21:45 +00:00
|
|
|
* FX Controller is the base class that all built-in FX use.
|
|
|
|
*
|
|
|
|
* You should not normally create an instance of this class directly, but instead use one of the built-in FX that extend it.
|
2023-02-13 21:21:18 +00:00
|
|
|
*
|
2023-02-17 01:08:52 +00:00
|
|
|
* @class Controller
|
2023-02-16 23:49:14 +00:00
|
|
|
* @memberof Phaser.FX
|
2023-02-13 21:21:18 +00:00
|
|
|
* @constructor
|
|
|
|
* @since 3.60.0
|
|
|
|
*
|
|
|
|
* @param {number} type - The FX Type constant.
|
|
|
|
* @param {Phaser.GameObjects.GameObject} gameObject - A reference to the Game Object that has this fx.
|
|
|
|
*/
|
2023-02-17 01:08:52 +00:00
|
|
|
var Controller = new Class({
|
2023-02-13 21:21:18 +00:00
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
2023-02-17 01:08:52 +00:00
|
|
|
function Controller (type, gameObject)
|
2023-02-13 21:21:18 +00:00
|
|
|
{
|
2023-02-16 22:15:22 +00:00
|
|
|
/**
|
|
|
|
* The FX_CONST type of this effect.
|
|
|
|
*
|
2023-02-17 01:08:52 +00:00
|
|
|
* @name Phaser.FX.Controller#type
|
2023-02-16 22:15:22 +00:00
|
|
|
* @type {number}
|
|
|
|
* @since 3.60.0
|
|
|
|
*/
|
2023-02-13 21:21:18 +00:00
|
|
|
this.type = type;
|
|
|
|
|
2023-02-16 22:15:22 +00:00
|
|
|
/**
|
|
|
|
* A reference to the Game Object that owns this effect.
|
|
|
|
*
|
2023-02-17 01:08:52 +00:00
|
|
|
* @name Phaser.FX.Controller#gameObject
|
2023-02-16 22:15:22 +00:00
|
|
|
* @type {Phaser.GameObjects.GameObject}
|
|
|
|
* @since 3.60.0
|
|
|
|
*/
|
2023-02-13 21:21:18 +00:00
|
|
|
this.gameObject = gameObject;
|
|
|
|
|
2023-02-16 22:15:22 +00:00
|
|
|
/**
|
|
|
|
* Toggle this boolean to enable or disable this effect,
|
|
|
|
* without removing and adding it from the Game Object.
|
|
|
|
*
|
2023-04-07 18:18:42 +00:00
|
|
|
* Only works for Pre FX.
|
|
|
|
*
|
|
|
|
* Post FX are always active.
|
|
|
|
*
|
2023-02-17 01:08:52 +00:00
|
|
|
* @name Phaser.FX.Controller#active
|
2023-02-16 22:15:22 +00:00
|
|
|
* @type {boolean}
|
|
|
|
* @since 3.60.0
|
|
|
|
*/
|
2023-02-13 21:21:18 +00:00
|
|
|
this.active = true;
|
|
|
|
},
|
|
|
|
|
2023-03-30 15:58:43 +00:00
|
|
|
/**
|
|
|
|
* Sets the active state of this FX Controller.
|
|
|
|
*
|
|
|
|
* A disabled FX Controller will not be updated.
|
|
|
|
*
|
|
|
|
* @method Phaser.FX.Controller#setActive
|
|
|
|
* @since 3.60.0
|
|
|
|
*
|
|
|
|
* @param {boolean} value - `true` to enable this FX Controller, or `false` to disable it.
|
|
|
|
*
|
|
|
|
* @return {this} This FX Controller instance.
|
|
|
|
*/
|
|
|
|
setActive: function (value)
|
|
|
|
{
|
|
|
|
this.active = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2023-02-17 17:07:22 +00:00
|
|
|
/**
|
|
|
|
* Destroys this FX Controller.
|
|
|
|
*
|
|
|
|
* @method Phaser.FX.Controller#destroy
|
|
|
|
* @since 3.60.0
|
|
|
|
*/
|
2023-02-13 21:21:18 +00:00
|
|
|
destroy: function ()
|
|
|
|
{
|
|
|
|
this.gameObject = null;
|
2023-02-17 17:07:22 +00:00
|
|
|
this.active = false;
|
2023-02-13 21:21:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2023-02-17 01:08:52 +00:00
|
|
|
module.exports = Controller;
|