Page 1 of 1

Text not centralizing

Posted: Fri Mar 04, 2016 1:27 am
by Kibita
Hey there!

I'm facing a problem where I can't centralize right my title:
Image

How can I make the text centralize correctly? I did this:

Code: Select all

-- Title
self.title = {}
self.title.text = "Sample Text"
self.title.width = fonts.menu:getWidth(self.title.text)
self.title.x = const.gameWidth / 2 - self.title.width / 2
self.title.y = 15

[....]

-- Draw title
love.graphics.setFont(fonts.title)
love.graphics.print(self.title.text, self.title.x, self.title.y)

Re: Text not centralizing

Posted: Fri Mar 04, 2016 1:46 am
by s-ol
You are using fonts.title to draw it but fonts.menu to calculate the width.

Re: Text not centralizing

Posted: Fri Mar 04, 2016 1:50 am
by Kibita
My god! Didn't noticed that. Anyway, thank you very much! I understood the difference now.

Re: Text not centralizing

Posted: Sun Mar 06, 2016 1:59 pm
by NickRock
These little mistakes are always so annoying right? :P