2017-07-04 00:59:31 +00:00
|
|
|
var BlendModes = require('../../renderer/BlendModes');
|
2017-02-23 03:10:48 +00:00
|
|
|
|
2018-02-01 00:04:45 +00:00
|
|
|
/**
|
|
|
|
* Provides methods used for setting the blend mode of a Game Object.
|
|
|
|
* Should be applied as a mixin and not used directly.
|
|
|
|
*
|
|
|
|
* @name Phaser.GameObjects.Components.BlendMode
|
|
|
|
* @mixin
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-02-23 03:10:48 +00:00
|
|
|
|
|
|
|
var BlendMode = {
|
|
|
|
|
2017-02-24 01:45:15 +00:00
|
|
|
_blendMode: BlendModes.NORMAL,
|
|
|
|
|
2018-02-01 00:04:45 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.GameObjects.Components.BlendMode#blendMode
|
|
|
|
* @type {integer|string}
|
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-02-23 03:10:48 +00:00
|
|
|
blendMode: {
|
|
|
|
|
|
|
|
get: function ()
|
|
|
|
{
|
2017-02-24 01:45:15 +00:00
|
|
|
return this._blendMode;
|
2017-02-23 03:10:48 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value)
|
|
|
|
{
|
2017-10-20 13:12:58 +00:00
|
|
|
if (typeof value === 'string')
|
|
|
|
{
|
|
|
|
value = BlendModes[value];
|
|
|
|
}
|
|
|
|
|
2017-02-23 03:10:48 +00:00
|
|
|
value | 0;
|
|
|
|
|
2017-08-03 01:09:59 +00:00
|
|
|
if (value >= 0)
|
2017-02-23 03:10:48 +00:00
|
|
|
{
|
2017-02-24 01:45:15 +00:00
|
|
|
this._blendMode = value;
|
2017-02-23 03:10:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-21 02:12:25 +00:00
|
|
|
},
|
|
|
|
|
2018-02-01 00:04:45 +00:00
|
|
|
/**
|
|
|
|
* Sets the Blend Mode being used by this Game Object.
|
|
|
|
*
|
|
|
|
* This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay)
|
|
|
|
*
|
|
|
|
* Under WebGL only the following Blend Modes are available:
|
|
|
|
*
|
|
|
|
* * ADD
|
|
|
|
* * MULTIPLY
|
|
|
|
* * SCREEN
|
|
|
|
*
|
|
|
|
* Canvas has more available depending on browser support.
|
|
|
|
*
|
|
|
|
* You can also create your own custom Blend Modes in WebGL.
|
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.Components.BlendMode.setBlendMode
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {string|integer} value - The BlendMode value. Either a string or a CONST.
|
|
|
|
*
|
|
|
|
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
|
|
|
|
*/
|
2017-04-21 02:12:25 +00:00
|
|
|
setBlendMode: function (value)
|
|
|
|
{
|
|
|
|
this.blendMode = value;
|
|
|
|
|
|
|
|
return this;
|
2017-02-23 03:10:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = BlendMode;
|