A Texture Source is the encapsulation of the actual source data for a Texture.
This is typically an Image Element, loaded from the file system or network, a Canvas Element or a Video Element.
A Texture can contain multiple Texture Sources, which only happens when a multi-atlas is loaded.
new TextureSource(texture, source, [width], [height], [flipY])
name | type | arguments | Default | description |
---|---|---|---|---|
texture | Phaser.Textures.Texture |
The Texture this TextureSource belongs to. |
||
source | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | WebGLTexture | Phaser.GameObjects.RenderTexture |
The source image data. |
||
width | number | <optional> |
Optional width of the source image. If not given it's derived from the source itself. |
|
height | number | <optional> |
Optional height of the source image. If not given it's derived from the source itself. |
|
flipY | boolean | <optional> | false |
Sets the |
Currently un-used.
Sets the UNPACK_FLIP_Y_WEBGL
flag the WebGL Texture uses during upload.
The current texture unit index as assigned by the WebGL Renderer. Un-used in canvas. Should be treated as read-only.
The counter value when this texture was last assigned an index by the WebGL Renderer. Un-used in canvas. Should be treated as read-only.
The WebGL Texture of the source image. If this TextureSource is driven from a WebGLTexture already, then this is a reference to that WebGLTexture.
The height of the source image. If not specified in the constructor it will check
the naturalHeight
and then height
properties of the source image.
The image data.
This is either an Image element, Canvas element or a Video Element.
Is the source image a Canvas Element?
Is the source image a WebGLTexture?
Are the source image dimensions a power of two?
Is the source image a Render Texture?
Is the source image a Video Element?
The Texture this TextureSource belongs to.
The resolution of the source image.
The Scale Mode the image will use when rendering. Either Linear or Nearest.
The source of the image data.
This is either an Image Element, a Canvas Element, a Video Element, a RenderTexture or a WebGLTexture.
The Texture this TextureSource belongs to.
The width of the source image. If not specified in the constructor it will check
the naturalWidth
and then width
properties of the source image.
Destroys this Texture Source and nulls the references.
Creates a WebGL Texture, if required, and sets the Texture filter mode.
name | type | description |
---|---|---|
game | Phaser.Game |
A reference to the Phaser Game instance. |
Sets the Filter Mode for this Texture.
The mode can be either Linear, the default, or Nearest.
For pixel-art you should use Nearest.
name | type | description |
---|---|---|
filterMode | Phaser.Textures.FilterMode |
The Filter Mode. |
Sets the UNPACK_FLIP_Y_WEBGL
flag for the WebGL Texture during texture upload.
name | type | arguments | Default | description |
---|---|---|---|---|
value | boolean | <optional> | true |
Should the WebGL Texture be flipped on the Y axis on texture upload or not? |
If this TextureSource is backed by a Canvas and is running under WebGL, it updates the WebGLTexture using the canvas data.