Basic Text
Create text objects using default settings, style configuration objects, or method chaining to set font properties like family, size, and color.
800 × 600
class Example extends Phaser.Scene
{
create ()
{
// Default text with no style settings
this.add.text(100, 100, 'Phaser');
// Pass in a basic style object with the constructor
this.add.text(100, 200, 'Phaser', { fontFamily: 'Arial', fontSize: 64, color: '#00ff00' });
// Or chain calls like this:
this.add.text(100, 400, 'Phaser').setFontFamily('Arial').setFontSize(64).setColor('#ffff00');
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.AUTO,
width: 800,
height: 600,
parent: 'game-container',
scene: Example
};
const game = new Phaser.Game(config);