phaser/src/gameobjects/components/Visible.js

68 lines
1.4 KiB
JavaScript
Raw Normal View History

// 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
* @mixin
* @since 3.0.0
*/
var Visible = {
_visible: true,
2018-02-01 01:09:34 +00:00
/**
* The visible state of the Game Object.
*
* An invisible Game Object will skip rendering, but still process update logic.
*
* @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.
*
* @method Phaser.GameObjects.Components.Visible.setVisible
* @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;