Create Text from Configuration

Demonstrates how to create and style a Text Game Object by passing a configuration object to the Scene Maker.

Create Text from Configuration, running
800 × 600
GitHub
class Example extends Phaser.Scene
{
    text;

    create ()
    {
        //  Implicit values
        const config1 = {
            x: 100,
            y: 100,
            text: 'Text\nGame Object\nCreated from config',
            style: {
                fontSize: '64px',
                fontFamily: 'Arial',
                color: '#ffffff',
                align: 'center',
                backgroundColor: '#ff00ff',
                shadow: {
                    color: '#000000',
                    fill: true,
                    offsetX: 2,
                    offsetY: 2,
                    blur: 8
                }
            }
        };

        this.make.text(config1);
    }
}

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

const game = new Phaser.Game(config);

More in Text29 examples