Skip to content

Commit e6f71e9

Browse files
committed
Graphics constructor now sets x/y parameters to zero if undefined. Before it would set them to undefined as the type check wasn't strict.
1 parent 4aa22e2 commit e6f71e9

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/gameobjects/GameObjectCreator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ Phaser.GameObjectCreator.prototype = {
237237
* Creates a new Graphics object.
238238
*
239239
* @method Phaser.GameObjectCreator#graphics
240-
* @param {number} x - X position of the new graphics object.
241-
* @param {number} y - Y position of the new graphics object.
240+
* @param {number} [x=0] - X position of the new graphics object.
241+
* @param {number} [y=0] - Y position of the new graphics object.
242242
* @return {Phaser.Graphics} The newly created graphics object.
243243
*/
244244
graphics: function (x, y) {

src/gameobjects/Graphics.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
* @extends Phaser.Component.LifeSpan
2222
* @extends Phaser.Component.PhysicsBody
2323
* @extends Phaser.Component.Reset
24-
* @param {Phaser.Game} game Current game instance.
25-
* @param {number} x - X position of the new graphics object.
26-
* @param {number} y - Y position of the new graphics object.
24+
* @param {Phaser.Game} game - Current game instance.
25+
* @param {number} [x=0] - X position of the new graphics object.
26+
* @param {number} [y=0] - Y position of the new graphics object.
2727
*/
2828
Phaser.Graphics = function (game, x, y) {
2929

30-
x = x || 0;
31-
y = y || 0;
30+
if (typeof x === 'undefined') { x = 0; }
31+
if (typeof y === 'undefined') { y = 0; }
3232

3333
/**
3434
* @property {number} type - The const type of this object.

0 commit comments

Comments
 (0)