Shape to Render Texture

Demonstrates how to draw Shape Game Objects, such as circles and rectangles, onto a Render Texture.

Shape to Render Texture, running
800 × 600
GitHub
class Example extends Phaser.Scene
{
    create ()
    {
        const rt = this.add.renderTexture(400, 300, 800, 600);

        const circle = this.add.circle(0, 0, 120, 0x6666ff).setVisible(false);
        const rect = this.add.rectangle(0, 0, 300, 64, 0xff0000).setVisible(false);

        rt.draw(circle, 300, 300);
        rt.draw(rect, 500, 300);
        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