Drawing Sprites to a Render Texture
Demonstrates how to draw multiple Game Objects into a Render Texture at specific coordinates and render the result.
800 × 600
class Example extends Phaser.Scene
{
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('bubble', 'assets/particles/bubble.png');
this.load.image('dude', 'assets/sprites/phaser-dude.png');
}
create ()
{
const bubble = this.add.image(0, 0, 'bubble');
const dude = this.add.image(0, 0, 'dude');
const rt = this.add.renderTexture(400, 300, 64, 64);
rt.draw(bubble, 32, 32);
rt.draw(dude, 32, 32);
rt.render();
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.AUTO,
parent: 'game-container',
width: 800,
height: 600,
backgroundColor: '#2d2d88',
scene: Example
};
const game = new Phaser.Game(config);