Build games as easily as you play them — join the Phaser Beam waitlist for Early Access.
class Example extends Phaser.Scene { create () { this.add.text(100, 20, 'Without Padding'); this.add.text(100, 100, 'Phaser').setFontSize(64).setFontStyle('bold italic').setFontFamily('Arial').setBackgroundColor('#0000ff'); this.add.text(100, 200, '继续').setFontSize(64).setFontStyle('bold italic').setFontFamily('Open Sans').setBackgroundColor('#0000ff'); this.add.text(450, 20, 'With Padding'); this.add.text(450, 100, 'Phaser').setFontSize(64).setFontStyle('bold italic').setFontFamily('Arial').setPadding({ right: 16 }).setBackgroundColor('#0000ff'); this.add.text(450, 200, '继续').setFontSize(64).setFontStyle('bold italic').setFontFamily('Open Sans').setPadding({ right: 16 }).setBackgroundColor('#0000ff'); } } const config = { type: Phaser.AUTO, width: 800, height: 600, parent: 'phaser-example', scene: Example }; const game = new Phaser.Game(config);
class Example extends Phaser.Scene
{
create ()
{
this.add.text(100, 20, 'Without Padding');
this.add.text(100, 100, 'Phaser').setFontSize(64).setFontStyle('bold italic').setFontFamily('Arial').setBackgroundColor('#0000ff');
this.add.text(100, 200, '继续').setFontSize(64).setFontStyle('bold italic').setFontFamily('Open Sans').setBackgroundColor('#0000ff');
this.add.text(450, 20, 'With Padding');
this.add.text(450, 100, 'Phaser').setFontSize(64).setFontStyle('bold italic').setFontFamily('Arial').setPadding({ right: 16 }).setBackgroundColor('#0000ff');
this.add.text(450, 200, '继续').setFontSize(64).setFontStyle('bold italic').setFontFamily('Open Sans').setPadding({ right: 16 }).setBackgroundColor('#0000ff');
}
}
const config = {
type: Phaser.AUTO,
width: 800,
height: 600,
parent: 'phaser-example',
scene: Example
};
const game = new Phaser.Game(config);