mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 13:13:43 +00:00
BitmapData has a new, optional, fifth argument: skipPool
. By default BitmapData objects will ask for the first free canvas found in the CanvasPool, but this behavior can now be customized on a per object basis.
This commit is contained in:
parent
cb0861d881
commit
0036bf747f
3 changed files with 6 additions and 11 deletions
|
@ -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.
|
||||
|
|
|
@ -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 !== '')
|
||||
{
|
||||
|
|
2
typescript/phaser.d.ts
vendored
2
typescript/phaser.d.ts
vendored
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue