diff --git a/src/gameobjects/BitmapData.js b/src/gameobjects/BitmapData.js index 890e1d246..04a807be5 100644 --- a/src/gameobjects/BitmapData.js +++ b/src/gameobjects/BitmapData.js @@ -19,11 +19,13 @@ * @param {string} key - Internal Phaser reference key for the BitmapData. * @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. +* @param {boolean} [skipPool=false] - When this BitmapData generates its internal canvas to use for rendering, it will get the canvas from the CanvasPool if false, or create its own if true. */ -Phaser.BitmapData = function (game, key, width, height) { +Phaser.BitmapData = function (game, key, width, height, skipPool) { if (width === undefined || width === 0) { width = 256; } if (height === undefined || height === 0) { height = 256; } + if (skipPool === undefined) { skipPool = false; } /** * @property {Phaser.Game} game - A reference to the currently running game. @@ -49,7 +51,7 @@ Phaser.BitmapData = function (game, key, width, height) { * @property {HTMLCanvasElement} canvas - The canvas to which this BitmapData draws. * @default */ - this.canvas = PIXI.CanvasPool.create(this, width, height); + this.canvas = Phaser.Canvas.create(this, width, height, null, skipPool); /** * @property {CanvasRenderingContext2D} context - The 2d context of the canvas. diff --git a/src/system/Canvas.js b/src/system/Canvas.js index d8e3155d8..fc3ca73c7 100644 --- a/src/system/Canvas.js +++ b/src/system/Canvas.js @@ -29,14 +29,7 @@ Phaser.Canvas = { width = width || 256; height = height || 256; - if (skipPool === undefined) - { - var canvas = PIXI.CanvasPool.create(parent, width, height); - } - else - { - var canvas = document.createElement('canvas'); - } + var canvas = (skipPool) ? document.createElement('canvas') : PIXI.CanvasPool.create(parent, width, height); if (typeof id === 'string' && id !== '') { diff --git a/typescript/phaser.d.ts b/typescript/phaser.d.ts index 3e5d78b21..8bf5fe49a 100644 --- a/typescript/phaser.d.ts +++ b/typescript/phaser.d.ts @@ -264,7 +264,7 @@ declare module Phaser { class BitmapData { - constructor(game: Phaser.Game, key: string, width?: number, height?: number); + constructor(game: Phaser.Game, key: string, width?: number, height?: number, skipPool?: boolean); baseTexture: PIXI.BaseTexture; buffer: ArrayBuffer;