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

Constructor

PIXI. BaseTexture

new BaseTexture(source, scaleMode)

A texture stores the information that represents an image. All textures have a base texture.

Parameters
Name Type Description
source String

the source object (image or canvas)

scaleMode Number

See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values

Source code: pixi/textures/BaseTexture.js (Line 9)

Public Properties

[readonly] hasLoaded : boolean

[read-only] Set to true once the base texture has loaded

Source code: pixi/textures/BaseTexture.js (Line 55)

[readonly] height : number

[read-only] The height of the base texture set when the image has loaded

Source code: pixi/textures/BaseTexture.js (Line 37)

imageUrl : string

Source code: pixi/textures/BaseTexture.js (Line 121)

mipmap : boolean

Set this to true if a mipmap of this texture needs to be generated. This value needs to be set before the texture is used Also the texture must be a power of two size to work

Source code: pixi/textures/BaseTexture.js (Line 92)

premultipliedAlpha : boolean

Controls if RGB channels should be pre-multiplied by Alpha (WebGL only)

Default Value
  • true
Source code: pixi/textures/BaseTexture.js (Line 74)

resolution : number

The Resolution of the texture.

Source code: pixi/textures/BaseTexture.js (Line 20)

scaleMode : number

The scale mode to apply when scaling this texture

Default Value
  • PIXI.scaleModes.LINEAR
Source code: pixi/textures/BaseTexture.js (Line 46)

source :Image

The image source that is used to create the texture.

Source code: pixi/textures/BaseTexture.js (Line 64)

[readonly] width : number

[read-only] The width of the base texture set when the image has loaded

Source code: pixi/textures/BaseTexture.js (Line 28)

Public Methods

<static> fromCanvas(canvas, scaleMode)

Helper function that creates a base texture from the given canvas element.

Parameters
Name Type Description
canvas Canvas

The canvas element source of the texture

scaleMode Number

See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values

Returns

BaseTexture

Source code: pixi/textures/BaseTexture.js (Line 281)

<static> fromImage(imageUrl, crossorigin, scaleMode)

Helper function that creates a base texture from the given image url. If the image is not in the base texture cache it will be created and loaded.

Parameters
Name Type Description
imageUrl String

The image url of the texture

crossorigin Boolean

-

scaleMode Number

See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values

Returns

BaseTexture

Source code: pixi/textures/BaseTexture.js (Line 238)

destroy()

Destroys this base texture

Source code: pixi/textures/BaseTexture.js (Line 156)

dirty()

Sets all glTextures to be dirty.

Source code: pixi/textures/BaseTexture.js (Line 197)

forceLoaded(width, height)

Forces this BaseTexture to be set as loaded, with the given width and height. Then calls BaseTexture.dirty. Important for when you don't want to modify the source object by forcing in complete or dimension properties it may not have.

Parameters
Name Type Description
width Number
  • The new width to force the BaseTexture to be.
height Number
  • The new height to force the BaseTexture to be.
Source code: pixi/textures/BaseTexture.js (Line 138)

unloadFromGPU()

Removes the base texture from the GPU, useful for managing resources on the GPU. Atexture is still 100% usable and will simply be reuploaded if there is a sprite on screen that is using it.

Source code: pixi/textures/BaseTexture.js (Line 210)

updateSourceImage(newSrc)

Changes the source image of the texture

Parameters
Name Type Description
newSrc String

the path of the image

Source code: pixi/textures/BaseTexture.js (Line 184)