Creates a Dynamic Texture instance and adds itself to this Texture Manager.
A Dynamic Texture is a special texture that allows you to draw textures, frames and most kind of Game Objects directly to it.
You can take many complex objects and draw them to this one texture, which can then be used as the base texture for other Game Objects, such as Sprites. Should you then update this texture, all Game Objects using it will instantly be updated as well, reflecting the changes immediately.
It's a powerful way to generate dynamic textures at run-time that are WebGL friendly and don't invoke expensive GPU uploads on each change.
See the methods available on the DynamicTexture
class for more details.
Optionally, you can also pass a Dynamic Texture instance to this method to have it added to the Texture Manager.
name | type | arguments | Default | description |
---|---|---|---|---|
key | string | Phaser.Textures.DynamicTexture |
The string-based key of this Texture. Must be unique within the Texture Manager. Or, a DynamicTexture instance. |
||
width | number | <optional> | 256 |
The width of this Dynamic Texture in pixels. Defaults to 256 x 256. Ignored if an instance is passed as the key. |
height | number | <optional> | 256 |
The height of this Dynamic Texture in pixels. Defaults to 256 x 256. Ignored if an instance is passed as the key. |
The Dynamic Texture that was created, or null
if the key is already in use.