phaser/src/gameobjects/components/Visible.js

84 lines
1.9 KiB
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
// bitmask flag for GameObject.renderMask
var _FLAG = 1; // 0001
2018-02-01 01:09:34 +00:00
/**
* Provides methods used for setting the visibility of a Game Object.
* Should be applied as a mixin and not used directly.
*
* @name Phaser.GameObjects.Components.Visible
* @since 3.0.0
*/
var Visible = {
2018-03-29 12:48:14 +00:00
/**
* Private internal value. Holds the visible value.
*
* @name Phaser.GameObjects.Components.Visible#_visible
* @type {boolean}
* @private
* @default true
* @since 3.0.0
*/
_visible: true,
2018-02-01 01:09:34 +00:00
/**
* The visible state of the Game Object.
*
2018-02-06 16:37:35 +00:00
* An invisible Game Object will skip rendering, but will still process update logic.
2018-02-01 01:09:34 +00:00
*
* @name Phaser.GameObjects.Components.Visible#visible
* @type {boolean}
* @since 3.0.0
*/
visible: {
get: function ()
{
return this._visible;
},
set: function (value)
{
if (value)
{
this._visible = true;
this.renderFlags |= _FLAG;
}
else
{
this._visible = false;
this.renderFlags &= ~_FLAG;
}
}
2017-06-27 21:44:16 +00:00
},
2018-02-01 01:09:34 +00:00
/**
* Sets the visibility of this Game Object.
2018-02-06 16:37:35 +00:00
*
* An invisible Game Object will skip rendering, but will still process update logic.
2018-02-01 01:09:34 +00:00
*
2018-02-01 01:36:52 +00:00
* @method Phaser.GameObjects.Components.Visible#setVisible
2018-02-01 01:09:34 +00:00
* @since 3.0.0
*
* @param {boolean} value - The visible state of the Game Object.
*
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
*/
2017-06-27 21:44:16 +00:00
setVisible: function (value)
{
this.visible = value;
2017-06-27 21:44:16 +00:00
return this;
}
};
module.exports = Visible;