Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Best way to center text inside a square?

Author
Message
2D Analyst
AGK Developer
19
Years of Service
User Offline
Joined: 2nd May 2004
Location:
Posted: 19th Mar 2019 12:10
I have the level menu screen setup and noticed the numbers are not align center inside the square.

I added logics to align 1 digital vs 2 digital, but even same length are not aligned center.

Example: 1 is center but 7 seems to be align more toward left side.

Is there a way to center number inside a square?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 19th Mar 2019 20:23
Are you using float values rather than integers?
Is it text created with CreateText() ?
If so you can use GetTextTotalWidth() to get the pixel width of the value
2D Analyst
AGK Developer
19
Years of Service
User Offline
Joined: 2nd May 2004
Location:
Posted: 20th Mar 2019 01:34
Works like a charm!

Login to post a reply

Server time is: 2024-04-26 12:21:25
Your offset time is: 2024-04-26 12:21:25