2017-02-23 03:10:48 +00:00
|
|
|
var Clamp = require('../math/Clamp');
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Alpha;
|