2017-07-04 00:59:31 +00:00
|
|
|
var Clamp = require('../../math/Clamp');
|
2017-02-23 03:10:48 +00:00
|
|
|
|
|
|
|
// Alpha Component
|
|
|
|
|
|
|
|
// bitmask flag for GameObject.renderMask
|
|
|
|
var _FLAG = 2; // 0010
|
|
|
|
|
|
|
|
var Alpha = {
|
|
|
|
|
2017-02-24 01:45:15 +00:00
|
|
|
_alpha: 1,
|
|
|
|
|
2017-02-23 03:10:48 +00:00
|
|
|
alpha: {
|
|
|
|
|
|
|
|
get: function ()
|
|
|
|
{
|
2017-02-24 01:45:15 +00:00
|
|
|
return this._alpha;
|
2017-02-23 03:10:48 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value)
|
|
|
|
{
|
2017-02-24 01:45:15 +00:00
|
|
|
this._alpha = Clamp(value, 0, 1);
|
2017-02-23 03:10:48 +00:00
|
|
|
|
2017-02-24 01:45:15 +00:00
|
|
|
if (this._alpha === 0)
|
2017-02-23 03:10:48 +00:00
|
|
|
{
|
|
|
|
this.renderFlags &= ~_FLAG;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.renderFlags |= _FLAG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-17 03:37:42 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
setAlpha: function (value)
|
|
|
|
{
|
|
|
|
this.alpha = value;
|
|
|
|
|
|
|
|
return this;
|
2017-02-23 03:10:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Alpha;
|