mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
BitmapData.shadow(color, blur, x, y) provides a quick way to set all the relevant shadow settings, which are then be used in future draw calls.
This commit is contained in:
parent
ef85b8415d
commit
26f9e05dca
2 changed files with 28 additions and 0 deletions
|
@ -88,6 +88,7 @@ Version 2.1.2 - "Whitebridge" - in development
|
|||
* Text.addColor allows you to set specific colors within the Text. It works by taking a color value, which is a typical HTML string such as `#ff0000` or `rgb(255,0,0)` and a position. The position value is the index of the character in the Text string to start applying this color to. Once set the color remains in use until either another color or the end of the string is encountered. For example if the Text was `Photon Storm` and you did `Text.addColor('#ffff00', 6)` it would color in the word `Storm` in yellow.
|
||||
* Text.clearColors resets any previously set colors from `Text.addColor`.
|
||||
* If you pass a tinted Sprite to `BitmapData.draw` or `BitmapData.copy` it will now draw the tinted version of the Sprite to the BitmapData and not the original texture.
|
||||
* BitmapData.shadow(color, blur, x, y) provides a quick way to set all the relevant shadow settings, which are then be used in future draw calls.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1071,6 +1071,33 @@ Phaser.BitmapData.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the shadow properties of this BitmapDatas context which will affect all draw operations made to it.
|
||||
* You can cancel an existing shadow by calling this method and passing no parameters.
|
||||
*
|
||||
* @method Phaser.BitmapData#shadow
|
||||
* @param {string} color - The color of the shadow, given in a CSS format, i.e. `#000000` or `rgba(0,0,0,1)`. If `null` or `undefined` the shadow will be reset.
|
||||
* @param {number} [blur=5] - The amount the shadow will be blurred by. Low values = a crisp shadow, high values = a softer shadow.
|
||||
* @param {number} [x=10] - The horizontal offset of the shadow in pixels.
|
||||
* @param {number} [y=10] - The vertical offset of the shadow in pixels.
|
||||
* @return {Phaser.BitmapData} This BitmapData object for method chaining.
|
||||
*/
|
||||
shadow: function (color, blur, x, y) {
|
||||
|
||||
if (typeof color === 'undefined' || color === null)
|
||||
{
|
||||
this.context.shadowColor = 'rgba(0,0,0,0)';
|
||||
}
|
||||
else
|
||||
{
|
||||
this.context.shadowColor = color;
|
||||
this.context.shadowBlur = blur || 5;
|
||||
this.context.shadowOffsetX = x || 10;
|
||||
this.context.shadowOffsetY = y || 10;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Draws the image onto this BitmapData using an image as an alpha mask.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue