Creates a texture from a display object that can be used for creating sprites and other textures. This is particularly useful for optimizing performance when a complex container needs to be reused.
Generate texture options or a container to convert to texture
A new RenderTexture containing the rendered display object
// Basic usage with a container
const container = new Container();
container.addChild(
new Graphics()
.circle(0, 0, 50)
.fill('red')
);
const texture = renderer.textureGenerator.generateTexture(container);
// Advanced usage with options
const texture = renderer.textureGenerator.generateTexture({
target: container,
frame: new Rectangle(0, 0, 100, 100), // Specific region
resolution: 2, // High DPI
clearColor: '#ff0000', // Red background
antialias: true // Smooth edges
});
// Create a sprite from the generated texture
const sprite = new Sprite(texture);
// Clean up when done
texture.destroy(true);
Generic destroy methods to be overridden by the subclass
System that manages the generation of textures from display objects in the renderer. This system is responsible for creating reusable textures from containers, sprites, and other display objects. Available through
renderer.textureGenerator
.Example
Features:
Common Use Cases:
Performance Considerations:
See