Skip to content

Commit 8f2c13f

Browse files
committed
CanvasPool has a new argument selfParent which allows the canvas itself to be the parent key, used for later removal.
1 parent 006d501 commit 8f2c13f

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/display/canvas/CanvasPool.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@ var CanvasPool = function ()
3636
* @param {integer} [width=1] - The width of the Canvas.
3737
* @param {integer} [height=1] - The height of the Canvas.
3838
* @param {integer} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`.
39+
* @param {boolean} [selfParent=false] - Use the generated Canvas element as the parent?
3940
*
4041
* @return {HTMLCanvasElement} [description]
4142
*/
42-
var create = function (parent, width, height, canvasType)
43+
var create = function (parent, width, height, canvasType, selfParent)
4344
{
4445
if (width === undefined) { width = 1; }
4546
if (height === undefined) { height = 1; }
4647
if (canvasType === undefined) { canvasType = CONST.CANVAS; }
48+
if (selfParent === undefined) { selfParent = false; }
4749

4850
var canvas;
4951
var container = first(canvasType);
@@ -70,6 +72,11 @@ var CanvasPool = function ()
7072
canvas = container.canvas;
7173
}
7274

75+
if (selfParent)
76+
{
77+
container.parent = canvas;
78+
}
79+
7380
canvas.width = width;
7481
canvas.height = height;
7582

0 commit comments

Comments
 (0)