Text to Render Texture

Demonstrates how to draw an invisible Text object onto a Render Texture and apply transformations using the Render Texture's internal camera rotation.

Text to Render Texture, running
800 × 600
GitHub
class Example extends Phaser.Scene
{
    text;
    rt;

    create ()
    {
        this.text = this.add.text(0, 0, 'Hello from a\nRender Texture').setFontSize(48);

        this.text.setVisible(false);

        this.rt = this.add.renderTexture(400, 300, 800, 600);
    }

    update ()
    {
        this.rt.camera.rotation -= 0.01;

        this.rt.clear();

        this.rt.draw(this.text, 400, 300);

        this.rt.render();
    }
}

const config = {
    scale: { mode: Phaser.Scale.FIT },
    type: Phaser.AUTO,
    parent: 'game-container',
    width: 800,
    height: 600,
    scene: Example
};

const game = new Phaser.Game(config);

More in Render Texture45 examples