Anyone knows what's wrong with these button texts?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
WAWAWA
Prole
Posts: 32
Joined: Fri Aug 13, 2021 5:10 pm

Anyone knows what's wrong with these button texts?

Post by WAWAWA »

I am very confused, as I have never created buttons before. I don't understand this, the text goes off when I do the following equation:

Code: Select all

love.graphics.print(
	text, font,
	(w/2) - #text,y
)
text = "Play Game"
font = Normal font
w = width of the box
h = height of the box
x = x pos of the box
y = y pos of the box
User avatar
dusoft
Party member
Posts: 501
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: Anyone knows what's wrong with these button texts?

Post by dusoft »

Use printf
See also viewtopic.php?t=10653
User avatar
BrotSagtMist
Party member
Posts: 612
Joined: Fri Aug 06, 2021 10:30 pm

Re: Anyone knows what's wrong with these button texts?

Post by BrotSagtMist »

May you give screenshot or actual code to what you get wrong?
Edit:
Actually i have a template for buttons, this is how i do them usually:
main.lua.love
(493 Bytes) Downloaded 76 times
obey
bizziboi
Citizen
Posts: 57
Joined: Sat Apr 16, 2011 9:24 am

Re: Anyone knows what's wrong with these button texts?

Post by bizziboi »

I am guessing your problem is that you subtract the number of characters in the the label in pixels.

You want to get the width of the rendered string and divide that by two instead?
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 34 guests