kidos Posted August 5, 2014 Share Posted August 5, 2014 I was trying to center my text on x point.I mean - I have a graphic placeholder for the score text, everything is working well but if the score is getting more figures the text is written right to left and the then it's getting out of the placeholder. In a regular text font I just add:this.scoreText.anchor.setTo(0.5,0);and the text is centered to the middle. Unfortunately the bitmapfont doesn't have this kind of member. Any ideas? Link to comment Share on other sites More sharing options...
lewster32 Posted August 5, 2014 Share Posted August 5, 2014 There is no in-built way to center single lines of BitmapText at the moment, but you can do this: http://www.html5gamedevs.com/topic/7129-how-to-center-a-bitmaptext/ kidos 1 Link to comment Share on other sites More sharing options...
codevinsky Posted August 5, 2014 Share Posted August 5, 2014 var text = game.add.bitmapText(100, 100, 'charlottesweb', 'Some Pig!', 24); text.x = text.x - text.textWidth / 2; text.y = text.y - text.textHeight / 2; kidos and lewster32 2 Link to comment Share on other sites More sharing options...
kidos Posted August 5, 2014 Author Share Posted August 5, 2014 both are working great but from some reason it's doesn't work with fixed to camera text, and my text is fixed to the camera Any ideas? Link to comment Share on other sites More sharing options...
kidos Posted August 5, 2014 Author Share Posted August 5, 2014 both are working great but from some reason it doesn't work with fixed to camera text, and my text is fixed to the camera Any ideas?ahh find it!! Since fixed to camera set the X (and Y) to the camera offset it can't be moved.But, we could use this one:this.scoreText.cameraOffset.x = this.posX - (this.scoreText.textWidth * 0.5);Thank you both! Link to comment Share on other sites More sharing options...
Recommended Posts