Skip to content

Commit af66b49

Browse files
committed
If a BitmapData is created with a width or height set to zero then the width and/or height are set to a default value (256) instead to avoid getContext errors.
1 parent 303929a commit af66b49

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ Version 2.4 - "Katar" - in dev
325325
* SoundManager.volume now has its input value clamped to ensure it's between 0 and 1 (inclusive)
326326
* Removed `Input.moveCallback` and `Input.moveCallbackContext` as neither are used any longer. Use `Input.addMoveCallback`.
327327
* SoundManager now uses the new `Touch.addTouchLockCallback` methods to handle mobile device audio unlocking.
328+
* If a BitmapData is created with a width or height set to zero then the width and/or height are set to a default value (256) instead to avoid getContext errors.
328329

329330
### Bug Fixes
330331

src/gameobjects/BitmapData.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
* @constructor
1414
* @param {Phaser.Game} game - A reference to the currently running game.
1515
* @param {string} key - Internal Phaser reference key for the BitmapData.
16-
* @param {number} [width=256] - The width of the BitmapData in pixels.
17-
* @param {number} [height=256] - The height of the BitmapData in pixels.
16+
* @param {number} [width=256] - The width of the BitmapData in pixels. If undefined or zero it's set to a default value.
17+
* @param {number} [height=256] - The height of the BitmapData in pixels. If undefined or zero it's set to a default value.
1818
*/
1919
Phaser.BitmapData = function (game, key, width, height) {
2020

21-
if (typeof width === 'undefined') { width = 256; }
22-
if (typeof height === 'undefined') { height = 256; }
21+
if (typeof width === 'undefined' || width === 0) { width = 256; }
22+
if (typeof height === 'undefined' || height === 0) { height = 256; }
2323

2424
/**
2525
* @property {Phaser.Game} game - A reference to the currently running game.

0 commit comments

Comments
 (0)