Jump to content

Sprites and text center


razorsese
 Share

Recommended Posts

I'm creating 6 circles and i want to draw on each of them a text right in the center but so far it is slightly offset from center

window.onload = function () {    var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render});    var circles;    var pos_x = [100,250,320,376,420,448];    var pos_y = [78,150,220,276,320,389];     function create_circles(){        	for(var i=1;i<=6;i++){    		var circle = game.add.sprite(pos_x[i], pos_y[i],"CIRCLE");    		circle.tint = 0xFF20A0;    		circle.scale.set(0.5,0.5);    		circle.inputEnabled = true;    		var style = { font: "10px Arial", fill: "#FFFFFF", wordWrap: true, wordWrapWidth: circle.width, align: "center" };    		circle.events.onInputDown.add(listener , this);    		text = game.add.text(pos_x[i], pos_y[i], "10", style);    		text.anchor.set(-1);    			    	    		}    }       function preload() {		this.game.load.image('CIRCLE', 'circle.png');    }    function create() {      game.stage.backgroundColor =  '#FFFFFF';      create_circles();    }    function update() {    }    function render () {    }    function listener(sprite, pointer){    	sprite.alpha = 0.5;        }};
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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