|
Submit
Your Own Code
PSP Lua CodeBase : Center TextDescription:
This is a simple function to print text to the screen centered. It's one of my
favorite C functions, so I'll post a lua version.
-- EVILMANA.COM PSP LUA CODEBASE
-- www.evilmana.com/tutorials/codebase
-- Center Text
-- SUBMITTED BY: Access_Denied
blue = Color.new(0,0,255)
function printCentered(y,text,color)
local length = string.len(text)
local x = 240 - ((length*8)/2)
screen:print(x,y,text,color)
end
while true do
screen:clear()
printCentered(100,"This is a test",blue)
printCentered(200,"This should be centered as well",blue)
screen.waitVblankStart()
screen.flip()
end
Back to CodeBase
|