General discussion about LÖVE, Lua, game development, puns, and unicorns.
-
Kibita
- Prole
- Posts: 31
- Joined: Tue Dec 29, 2015 7:46 pm
Post
by Kibita »
Hey there!
I'm facing a problem where I can't centralize right my title:
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)
-
s-ol
- Party member
- Posts: 1077
- Joined: Mon Sep 15, 2014 7:41 pm
- Location: Cologne, Germany
-
Contact:
Post
by s-ol »
You are using fonts.title to draw it but fonts.menu to calculate the width.
-
Kibita
- Prole
- Posts: 31
- Joined: Tue Dec 29, 2015 7:46 pm
Post
by Kibita »
My god! Didn't noticed that. Anyway, thank you very much! I understood the difference now.
-
NickRock
- Citizen
- Posts: 76
- Joined: Thu Dec 25, 2014 9:33 pm
- Location: Earth
-
Contact:
Post
by NickRock »
These little mistakes are always so annoying right?
Weeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeooow!!
Users browsing this forum: No registered users and 9 guests