Jump to content

Why don't text center?


stone
 Share

Recommended Posts

 Why not centered on the sprite??????

var game = new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.AUTO, 'game_div');    var scale = window.innerHeight/9;    var main_state = {        preload: function() {            game.load.image('hello', 'assets/bird1.png');        },        create: function() {           this.hello = this.game.add.sprite(20, 20, 'hello');          this.hello.width = this.hello.height = scale;          var text = game.add.text(0, 0, '10', {font: parseInt(scale/2)+'px arial', fill: '#aaa'});          this.hello.addChild(text);          text.position.x = (scale - text.width)/2;          text.position.y = (scale - text.height)/2;        },        update: function() {                    }    };    game.state.add('main', main_state);      game.state.start('main'); 
Link to comment
Share on other sites

  • 2 weeks later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...