![]() |
|
Centering text. |
julian_boolean
Member #8,201
January 2007
|
I want to put text over a graphic, like a button or whatever, and have it centered. Right now I'm just doing it manually by adding onto the x position of the text until it looks good, which is a pain in the ass. |
23yrold3yrold
Member #1,134
March 2001
![]() |
-- |
julian_boolean
Member #8,201
January 2007
|
Omigod omigod omigod! Are you single? |
SonShadowCat
Member #1,548
September 2001
![]() |
A thank you would suffice |
Jonatan Hedborg
Member #4,886
July 2004
![]() |
Please bookmark this: http://www.allegro.cc/manual/ Please. (oh, and the alternative method would be to use text_length(font,"the text"), and subtract half that from the x value)
|
julian_boolean
Member #8,201
January 2007
|
Top right corner. The previous question was much more then a thank you Edit: That works.. But if I move the image the text was over then the text will remain in the same spot (because I'm no longer giving it the image's current x and y position.) Nm I think. textout_centre_ex(buffer, font, caption.c_str(), xPos + width / 2, yPos, WHITE, -1);
|
TeamTerradactyl
Member #7,733
September 2006
![]() |
If you create a button, you know the button's coordinates. When you use textout_centre_ex, simply use the button's xPos,yPos coordinates, and the centered text should correctly align no matter where the button is located on the screen. textout_centre_ex(buffer, font, caption.c_str(), button_xPos + width / 2, button_yPos, WHITE, -1);
|
|