phaser/src/gameobjects/components/BlendMode.js

79 lines
1.7 KiB
JavaScript
Raw Normal View History

var BlendModes = require('../../renderer/BlendModes');
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
*/
var BlendMode = {
_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
*/
blendMode: {
get: function ()
{
return this._blendMode;
},
set: function (value)
{
if (typeof value === 'string')
{
value = BlendModes[value];
}
value | 0;
if (value >= 0)
{
this._blendMode = value;
}
}
},
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.
*/
setBlendMode: function (value)
{
this.blendMode = value;
return this;
}
};
module.exports = BlendMode;