Class: CanvasPool

Phaser. CanvasPool

new CanvasPool()

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

Source:
src/utils/CanvasPool.js line 13

Members

<static> pool : Array

The pool into which the canvas elements are placed.

Type:
  • Array
Source:
src/utils/CanvasPool.js line 186

Methods

<static> create(parent, width, height)

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

Parameters:
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.

Source:
src/utils/CanvasPool.js line 15
Returns:

The canvas element.

Type
HTMLCanvasElement

<static> getFirst()

Gets the first free canvas index from the pool.

Source:
src/utils/CanvasPool.js line 58
Returns:
Type
number

<static> getFree()

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

Source:
src/utils/CanvasPool.js line 153
Returns:

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

Type
number

<static> getTotal()

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

Source:
src/utils/CanvasPool.js line 129
Returns:

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

Type
number

<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.

Parameters:
Name Type Description
parent any

The parent of the canvas element.

Source:
src/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.

Parameters:
Name Type Description
canvas HTMLCanvasElement

The canvas element to remove.

Source:
src/utils/CanvasPool.js line 105

phaser-ce@2.8.8 is on GitHub and NPM

Documentation generated by JSDoc 3.5.4 on 2017-09-25 using Tomorrow.