Phaser API Documentation

  Version: 
Filter
Namespace: CanvasPool
Phaser.Display.Canvas.CanvasPool

Methods

<static> create(parent, [width], [height], [canvasType], [selfParent])
Focus
Focus

Description:

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

Parameters:

name type arguments Default description
parent *

The parent of the Canvas object.

width number <optional> 1

The width of the Canvas.

height number <optional> 1

The height of the Canvas.

canvasType number <optional> Phaser.CANVAS

The type of the Canvas. Either Phaser.CANVAS or Phaser.WEBGL.

selfParent boolean <optional> false

Use the generated Canvas element as the parent?

Returns:
Description:

The canvas element that was created or pulled from the pool

Type:
  • HTMLCanvasElement
Since: 3.0.0
Focus
Focus
<static> create2D(parent, [width], [height])
Focus
Focus

Description:

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

Parameters:

name type arguments Default description
parent *

The parent of the Canvas object.

width number <optional> 1

The width of the Canvas.

height number <optional> 1

The height of the Canvas.

Returns:
Description:

The created canvas.

Type:
  • HTMLCanvasElement
Since: 3.0.0
Focus
Focus
<static> createWebGL(parent, [width], [height])
Focus
Focus

Description:

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

Parameters:

name type arguments Default description
parent *

The parent of the Canvas object.

width number <optional> 1

The width of the Canvas.

height number <optional> 1

The height of the Canvas.

Returns:
Description:

The created WebGL canvas.

Type:
  • HTMLCanvasElement
Since: 3.0.0
Focus
Focus
<static> first([canvasType])
Focus
Focus

Description:

Gets the first free canvas index from the pool.

Parameters:

name type arguments Default description
canvasType number <optional> Phaser.CANVAS

The type of the Canvas. Either Phaser.CANVAS or Phaser.WEBGL.

Returns:
Description:

The first free canvas, or null if a WebGL canvas was requested or if the pool doesn't have free canvases.

Type:
  • HTMLCanvasElement
Since: 3.0.0
Focus
Focus
<static> remove(parent)
Focus
Focus

Description:

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 *

The canvas or the parent of the canvas to free.

Since: 3.0.0
Focus
Focus
<static> total()
Focus
Focus

Description:

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

Returns:
Description:

The number of used canvases.

Type:
  • number
Since: 3.0.0
Focus
Focus
<static> free()
Focus
Focus

Description:

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

Returns:
Description:

The number of free canvases.

Type:
  • number
Since: 3.0.0
Focus
Focus
<static> disableSmoothing()
Focus
Focus

Description:

Disable context smoothing on any new Canvas element created.

Since: 3.0.0
Focus
Focus
<static> enableSmoothing()
Focus
Focus

Description:

Enable context smoothing on any new Canvas element created.

Since: 3.0.0
Focus
Focus