spinnerbox Posted April 9, 2015 Share Posted April 9, 2015 I just found that Phaser uses Pixi to render text and also found that align property, which by default is 'left' does not apply to single line text. I need it to be centered. I just want to display score text. I can position the field in middle of my text border but only when it has a value of '0'. When it has value of '12000' it looks like it is shifted towards right side of the border. What would you do in this case? What is the best way to pass this problem without changing 'x' coordinate of the text field? I am making a Phaser 2.2.2 game. Quote Link to comment Share on other sites More sharing options...
Neso Posted April 10, 2015 Share Posted April 10, 2015 I am not familiar with Phaser. However, you can change anchor point to the middle of the text. That way it will always look centred. http://www.goodboydigital.com/pixijs/docs/classes/Text.html#property_anchor spinnerbox 1 Quote Link to comment Share on other sites More sharing options...
spinnerbox Posted April 13, 2015 Author Share Posted April 13, 2015 It works, thank you. Edit: In Phaser you would do:spriteObject.anchor.set(0.5, 0.5); Quote Link to comment Share on other sites More sharing options...
xerver Posted April 13, 2015 Share Posted April 13, 2015 Just so anyone else who lands here isn't confused, the code you posted @spinnerbox has nothing to do with Phaser. Phaser sprites inherit from PIXI.Sprite, which has a property `.anchor` which is a PIXI.Point. A pixi user that doesn't use Phaser would update the anchor in the same manner as you just posted. spinnerbox 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.