Skip to content

Commit def662f

Browse files
committed
Text.setShadow has had the default color value changed from rgba(0,0,0,0) to rgba(0,0,0,1) so it appears as a black shadow by default - before the alpha channel made it invisible.
1 parent 03ebb8d commit def662f

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ removal of the automatic closure, results in a very lightweight
223223
* With this change in place Signals now consume less than 50KB / 50KB (shallow / retained memory) for 200 sprites, where-as before they used 300KB / 600KB (thanks @pnstickne #1359)
224224
* Time.elapsedMS holds the number of milliseconds since the last Game loop, regardless of raF or setTimout being used.
225225
* Incorrectly prepared tilemap images (with dimensions not evenly divisible by the tile dimensions) would render incorrectly when compared to the display seen in Tiled. The Phaser tilemap code has been adjusted to match the way Tiled deals with this, which should help if you're using tileset images that contain extra padding/margin pixels. Additional console warnings have been added. However the fact remains that you should carefully prepare your tilesets before using them. Crop off extra padding, make sure they are the right dimensions (thanks @SoulBeaver for the report and @pnstickne for the fix #1371)
226+
* Text.setShadow has had the default `color` value changed from `rgba(0,0,0,0)` to `rgba(0,0,0,1)` so it appears as a black shadow by default - before the alpha channel made it invisible.
226227

227228
### Bug Fixes
228229

src/gameobjects/Text.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* @param {number} x - X position of the new text object.
1717
* @param {number} y - Y position of the new text object.
1818
* @param {string} text - The actual text that will be written.
19-
* @param {object} style - The style object containing style attributes like font, font size ,
19+
* @param {object} style - The style object containing style attributes like font, font size, etc.
2020
*/
2121
Phaser.Text = function (game, x, y, text, style) {
2222

@@ -295,20 +295,28 @@ Phaser.Text.prototype.destroy = function (destroyChildren) {
295295
};
296296

297297
/**
298-
* Sets a drop-shadow effect on the Text.
298+
* Sets a drop shadow effect on the Text. You can specify the horizontal and vertical distance of the drop shadow with the `x` and `y` parameters.
299+
* The color controls the shade of the shadow (default is black) and can be either an `rgba` or `hex` value.
300+
* The blur is the strength of the shadow. A value of zero means a hard shadow, a value of 10 means a very soft shadow.
301+
* To remove a shadow already in place you can call this method with no parameters set.
299302
*
300303
* @method Phaser.Text#setShadow
301304
* @param {number} [x=0] - The shadowOffsetX value in pixels. This is how far offset horizontally the shadow effect will be.
302305
* @param {number} [y=0] - The shadowOffsetY value in pixels. This is how far offset vertically the shadow effect will be.
303-
* @param {string} [color='rgba(0,0,0,0)'] - The color of the shadow, as given in CSS rgba format. Set the alpha component to 0 to disable the shadow.
306+
* @param {string} [color='rgba(0,0,0,1)'] - The color of the shadow, as given in CSS rgba or hex format. Set the alpha component to 0 to disable the shadow.
304307
* @param {number} [blur=0] - The shadowBlur value. Make the shadow softer by applying a Gaussian blur to it. A number from 0 (no blur) up to approx. 10 (depending on scene).
305308
*/
306309
Phaser.Text.prototype.setShadow = function (x, y, color, blur) {
307310

308-
this.style.shadowOffsetX = x || 0;
309-
this.style.shadowOffsetY = y || 0;
310-
this.style.shadowColor = color || 'rgba(0,0,0,0)';
311-
this.style.shadowBlur = blur || 0;
311+
if (typeof x === 'undefined') { x = 0; }
312+
if (typeof y === 'undefined') { y = 0; }
313+
if (typeof color === 'undefined') { color = 'rgba(0, 0, 0, 1)'; }
314+
if (typeof blur === 'undefined') { blur = 0; }
315+
316+
this.style.shadowOffsetX = x;
317+
this.style.shadowOffsetY = y;
318+
this.style.shadowColor = color;
319+
this.style.shadowBlur = blur;
312320
this.dirty = true;
313321

314322
};

0 commit comments

Comments
 (0)