Phaser.CanvasPool

new CanvasPool()

The CanvasPool is a global static object, that allows Phaser to recycle and pool Canvas DOM elements.

Source - utils/CanvasPool.js, line 13

Members

<static> pool:Array

The pool into which the canvas elements are placed.

Source - utils/CanvasPool.js, line 186

Methods

<static> create(parent, width, height)→ {HTMLCanvasElement}

Creates a new Canvas DOM element, or pulls one from the pool if free.

Name

Type

Description

parent

any

The parent of the canvas element.

width

number

The width of the canvas element.

height

number

The height of the canvas element.

HTMLCanvasElement-

The canvas element.

Source - utils/CanvasPool.js, line 15

<static>getFirst()→ {number}

Gets the first free canvas index from the pool.

number-

Source - utils/CanvasPool.js, line 58

<static>getFree()→ {number}

Gets the total number of free canvas elements in the pool.

number-

The number of free (un-parented) canvas elements in the pool.

Source - utils/CanvasPool.js, line 153

<static> getTotal()→ {number}

Gets the total number of used canvas elements in the pool.

number-

The number of in-use (parented) canvas elements in the pool.

Source - utils/CanvasPool.js, line 129

<static> remove(parent)

Looks up a canvas based on its parent, and if found puts it back in the pool, freeing it up for re-use. The canvas has its width and height set to 1, and its parent attribute nulled.

Name

Type

Description

parent

any

The parent of the canvas element.

Source - utils/CanvasPool.js, line 81

<static>removeByCanvas(canvas)

Looks up a canvas based on its type, and if found puts it back in the pool, freeing it up for re-use. The canvas has its width and height set to 1, and its parent attribute nulled.

Name

Type

Description

canvas

HTMLCanvasElement

The canvas element to remove.

Source - utils/CanvasPool.js, line 105