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.

This commit is contained in:
photonstorm 2015-05-06 16:50:10 +01:00
parent 303929a3ce
commit af66b49f31
2 changed files with 5 additions and 4 deletions

View file

@ -325,6 +325,7 @@ Version 2.4 - "Katar" - in dev
* SoundManager.volume now has its input value clamped to ensure it's between 0 and 1 (inclusive)
* Removed `Input.moveCallback` and `Input.moveCallbackContext` as neither are used any longer. Use `Input.addMoveCallback`.
* SoundManager now uses the new `Touch.addTouchLockCallback` methods to handle mobile device audio unlocking.
* 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.
### Bug Fixes

View file

@ -13,13 +13,13 @@
* @constructor
* @param {Phaser.Game} game - A reference to the currently running game.
* @param {string} key - Internal Phaser reference key for the BitmapData.
* @param {number} [width=256] - The width of the BitmapData in pixels.
* @param {number} [height=256] - The height of the BitmapData in pixels.
* @param {number} [width=256] - The width of the BitmapData in pixels. If undefined or zero it's set to a default value.
* @param {number} [height=256] - The height of the BitmapData in pixels. If undefined or zero it's set to a default value.
*/
Phaser.BitmapData = function (game, key, width, height) {
if (typeof width === 'undefined') { width = 256; }
if (typeof height === 'undefined') { height = 256; }
if (typeof width === 'undefined' || width === 0) { width = 256; }
if (typeof height === 'undefined' || height === 0) { height = 256; }
/**
* @property {Phaser.Game} game - A reference to the currently running game.