mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 06:28:30 +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 {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} [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 {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 (width === undefined || width === 0) { width = 256; }
|
||||||
if (height === undefined || height === 0) { height = 256; }
|
if (height === undefined || height === 0) { height = 256; }
|
||||||
|
if (skipPool === undefined) { skipPool = false; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {Phaser.Game} game - A reference to the currently running game.
|
* @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.
|
* @property {HTMLCanvasElement} canvas - The canvas to which this BitmapData draws.
|
||||||
* @default
|
* @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.
|
* @property {CanvasRenderingContext2D} context - The 2d context of the canvas.
|
||||||
|
|
|
@ -29,14 +29,7 @@ Phaser.Canvas = {
|
||||||
width = width || 256;
|
width = width || 256;
|
||||||
height = height || 256;
|
height = height || 256;
|
||||||
|
|
||||||
if (skipPool === undefined)
|
var canvas = (skipPool) ? document.createElement('canvas') : PIXI.CanvasPool.create(parent, width, height);
|
||||||
{
|
|
||||||
var canvas = PIXI.CanvasPool.create(parent, width, height);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var canvas = document.createElement('canvas');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof id === 'string' && id !== '')
|
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 {
|
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;
|
baseTexture: PIXI.BaseTexture;
|
||||||
buffer: ArrayBuffer;
|
buffer: ArrayBuffer;
|
||||||
|
|
Loading…
Add table
Reference in a new issue