Navigation
These archived docs are for Phaser 2.2.2 Phaser 3 docs can be found on newdocs.phaser.io.
Phaser CE docs can be found on the Phaser CE Documentation site.

Constructor

Phaser. RenderTexture

new RenderTexture(game, key, width, height, key, scaleMode, resolution)

A RenderTexture is a special texture that allows any displayObject to be rendered to it. It allows you to take many complex objects and render them down into a single quad (on WebGL) which can then be used to texture other display objects with. A way of generating textures at run-time.

Parameters
Name Type Argument Default Description
game Phaser.Game

Current game instance.

key string

Internal Phaser reference key for the render texture.

width number <optional>
100

The width of the render texture.

height number <optional>
100

The height of the render texture.

key string <optional>
''

The key of the RenderTexture in the Cache, if stored there.

scaleMode number <optional>
Phaser.scaleModes.DEFAULT

One of the Phaser.scaleModes consts.

resolution number <optional>
1

The resolution of the texture being generated.

Source code: gameobjects/RenderTexture.js, line 22

Extends

Public Properties

baseTexture : PIXI.BaseTexture

The base texture object that this texture uses

Inherited From
Source code: pixi/textures/RenderTexture.js, line 78

crop : PIXI.Rectangle

This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering, irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases)

Inherited From
Source code: pixi/textures/RenderTexture.js, line 69

frame : PIXI.Rectangle

The framing rectangle of the render texture

Inherited From
Source code: pixi/textures/RenderTexture.js, line 61

game : Phaser.Game

A reference to the currently running game.

Source code: gameobjects/RenderTexture.js, line 31

height : number

The height of the render texture

Inherited From
Source code: pixi/textures/RenderTexture.js, line 45

key : string

The key of the RenderTexture in the Cache, if stored there.

Source code: gameobjects/RenderTexture.js, line 36

matrix : PIXI.Matrix

The matrix that is applied when display objects are rendered to this RenderTexture.

Source code: gameobjects/RenderTexture.js, line 46

noFrame : boolean

Does this Texture have any frame data assigned to it?

Inherited From
Source code: pixi/textures/Texture.js, line 24

renderer : PIXI.CanvasRenderer | PIXI.WebGLRenderer

The renderer this RenderTexture uses. A RenderTexture can only belong to one renderer at the moment if its webGL.

Type
Inherited From
Source code: pixi/textures/RenderTexture.js, line 99

requiresUpdate : boolean

This will let a renderer know that a texture has been updated (used mainly for webGL uv updates)

Inherited From
Source code: pixi/textures/Texture.js, line 75

resolution : number

The Resolution of the texture.

Inherited From
Source code: pixi/textures/RenderTexture.js, line 53

trim : PIXI.Rectangle

The texture trim data.

Inherited From
Source code: pixi/textures/Texture.js, line 59

type : number

Base Phaser object type.

Source code: gameobjects/RenderTexture.js, line 41

valid : boolean

Inherited From
Source code: pixi/textures/RenderTexture.js, line 125

width : number

The with of the render texture

Inherited From
Source code: pixi/textures/RenderTexture.js, line 37

Public Methods

clear()

Clears the RenderTexture.

Inherited From
Source code: pixi/textures/RenderTexture.js, line 171

destroy(destroyBase)

Destroys this texture

Parameters
Name Type Description
destroyBase Boolean

Whether to destroy the base texture as well

Inherited From
Source code: pixi/textures/Texture.js, line 149

getBase64() → {String}

Will return a a base64 encoded string of this texture. It works by calling RenderTexture.getCanvas and then running toDataURL on that.

Returns
String -

A base64 encoded string of the texture.

Inherited From
Source code: pixi/textures/RenderTexture.js, line 291

getCanvas() → {HTMLCanvasElement}

Creates a Canvas element, renders this RenderTexture to it and then returns it.

Returns
HTMLCanvasElement -

A Canvas element with the texture rendered on.

Inherited From
Source code: pixi/textures/RenderTexture.js, line 302

getImage() → {Image}

Will return a HTML Image of the texture

Returns
Image -
Inherited From
Source code: pixi/textures/RenderTexture.js, line 278

render(displayObject, position, clear)

This function will draw the display object to the texture.

Parameters
Name Type Description
displayObject Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Group

The display object to render to this texture.

position Phaser.Point

A Point object containing the position to render the display object at.

clear boolean

If true the texture will be cleared before the display object is drawn.

Source code: gameobjects/RenderTexture.js, line 82

renderXY(displayObject, x, y, clear)

This function will draw the display object to the texture.

Parameters
Name Type Description
displayObject Phaser.Sprite | Phaser.Image | Phaser.Text | Phaser.BitmapText | Phaser.Group

The display object to render to this texture.

x number

The x position to render the object at.

y number

The y position to render the object at.

clear boolean

If true the texture will be cleared before the display object is drawn.

Source code: gameobjects/RenderTexture.js, line 57

resize(width, height, updateBase)

Resizes the RenderTexture.

Parameters
Name Type Description
width Number

The width to resize to.

height Number

The height to resize to.

updateBase Boolean

Should the baseTexture.width and height values be resized as well?

Inherited From
Source code: pixi/textures/RenderTexture.js, line 137

setFrame(frame)

Specifies the region of the baseTexture that this texture will use.

Parameters
Name Type Description
frame PIXI.Rectangle

The frame of the texture to set it to

Inherited From
Source code: pixi/textures/Texture.js, line 162