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:
Richard Davey 2018-04-23 23:39:12 +01:00
parent 006d501fbe
commit 8f2c13f4c8

View file

@ -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;