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.

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.

Returns:
HTMLCanvasElement -

The canvas element.

Source - utils/CanvasPool.js, line 15

<static> getFirst() → {number}

Gets the first free canvas index from the pool.

Returns:
number -
Source - utils/CanvasPool.js, line 58

<static> getFree() → {number}

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

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

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

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

Parameters:
Name Type Description
canvas HTMLCanvasElement

The canvas element to remove.

Source - utils/CanvasPool.js, line 105
Phaser Copyright © 2012-2016 Photon Storm Ltd.
Documentation generated by JSDoc 3.4.3 on Tue Dec 06 2016 23:48:57 GMT+0000 (GMT Standard Time) using the DocStrap template.