var config = { type: Phaser.AUTO, parent: 'phaser-example', width: 800, height: 600, scene: { preload: preload, create: create, update: update } }; var rt; var bitmaptext; var game = new Phaser.Game(config); function preload () { this.load.setBaseURL('https://cdn.phaserfiles.com/v355'); this.load.bitmapFont('desyrel', 'assets/fonts/bitmap/desyrel.png', 'assets/fonts/bitmap/desyrel.xml'); } function create () { bitmaptext = this.add.dynamicBitmapText(0, 0, 'desyrel', 'PHASER 3\nRender Texture', 64); bitmaptext.setDisplayCallback(textCallback); bitmaptext.setVisible(false); rt = this.add.renderTexture(0, 0, 800, 600); } function update () { rt.camera.rotation -= 0.01; rt.clear(); rt.draw(bitmaptext, 300, 400); } // data = { index: index, charCode: charCode, x: x, y: y, scaleX: scaleX, scaleY: scaleY } function textCallback (data) { data.x = Phaser.Math.Between(data.x - 2, data.x + 2); data.y = Phaser.Math.Between(data.y - 4, data.y + 4); return data; }
Scan to open on your mobile device
var config = { type: Phaser.AUTO, parent: 'phaser-example', width: 800, height: 600, scene: { preload: preload, create: create, update: update } }; var rt; var bitmaptext; var game = new Phaser.Game(config); function preload () { this.load.setBaseURL('https://cdn.phaserfiles.com/v355'); this.load.bitmapFont('desyrel', 'assets/fonts/bitmap/desyrel.png', 'assets/fonts/bitmap/desyrel.xml'); } function create () { bitmaptext = this.add.dynamicBitmapText(0, 0, 'desyrel', 'PHASER 3\nRender Texture', 64); bitmaptext.setDisplayCallback(textCallback); bitmaptext.setVisible(false); rt = this.add.renderTexture(0, 0, 800, 600); } function update () { rt.camera.rotation -= 0.01; rt.clear(); rt.draw(bitmaptext, 300, 400); } // data = { index: index, charCode: charCode, x: x, y: y, scaleX: scaleX, scaleY: scaleY } function textCallback (data) { data.x = Phaser.Math.Between(data.x - 2, data.x + 2); data.y = Phaser.Math.Between(data.y - 4, data.y + 4); return data; }