|
16 | 16 | * @param {number} x - X position of the new text object. |
17 | 17 | * @param {number} y - Y position of the new text object. |
18 | 18 | * @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. |
20 | 20 | */ |
21 | 21 | Phaser.Text = function (game, x, y, text, style) { |
22 | 22 |
|
@@ -295,20 +295,28 @@ Phaser.Text.prototype.destroy = function (destroyChildren) { |
295 | 295 | }; |
296 | 296 |
|
297 | 297 | /** |
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. |
299 | 302 | * |
300 | 303 | * @method Phaser.Text#setShadow |
301 | 304 | * @param {number} [x=0] - The shadowOffsetX value in pixels. This is how far offset horizontally the shadow effect will be. |
302 | 305 | * @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. |
304 | 307 | * @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). |
305 | 308 | */ |
306 | 309 | Phaser.Text.prototype.setShadow = function (x, y, color, blur) { |
307 | 310 |
|
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; |
312 | 320 | this.dirty = true; |
313 | 321 |
|
314 | 322 | }; |
|
0 commit comments