mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 21:24:09 +00:00
CanvasPool has a new argument selfParent
which allows the canvas itself to be the parent key, used for later removal.
This commit is contained in:
parent
006d501fbe
commit
8f2c13f4c8
1 changed files with 8 additions and 1 deletions
|
@ -36,14 +36,16 @@ var CanvasPool = function ()
|
|||
* @param {integer} [width=1] - The width of the Canvas.
|
||||
* @param {integer} [height=1] - The height of the Canvas.
|
||||
* @param {integer} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`.
|
||||
* @param {boolean} [selfParent=false] - Use the generated Canvas element as the parent?
|
||||
*
|
||||
* @return {HTMLCanvasElement} [description]
|
||||
*/
|
||||
var create = function (parent, width, height, canvasType)
|
||||
var create = function (parent, width, height, canvasType, selfParent)
|
||||
{
|
||||
if (width === undefined) { width = 1; }
|
||||
if (height === undefined) { height = 1; }
|
||||
if (canvasType === undefined) { canvasType = CONST.CANVAS; }
|
||||
if (selfParent === undefined) { selfParent = false; }
|
||||
|
||||
var canvas;
|
||||
var container = first(canvasType);
|
||||
|
@ -70,6 +72,11 @@ var CanvasPool = function ()
|
|||
canvas = container.canvas;
|
||||
}
|
||||
|
||||
if (selfParent)
|
||||
{
|
||||
container.parent = canvas;
|
||||
}
|
||||
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
|
||||
|
|
Loading…
Reference in a new issue