40 lines
1.0 KiB
Lua
40 lines
1.0 KiB
Lua
local ScrollScale = 0
|
|
local ScrollOffsetX = 0
|
|
|
|
function textmaker(text, fontsize, maxWidth, x, y, w, h, scissorX, scissorY, debugX, debugY,deltaTime)
|
|
gfx.FontSize(fontsize)
|
|
local x1,y1,x2,y2 = gfx.TextBounds(x,y, text)
|
|
gfx.FillColor(255,0,0) --*
|
|
-- gfx.Text((x2-x1).." Box",x+debugX,y+debugY/1.5) --*
|
|
|
|
|
|
gfx.Scissor(x,y + scissorY,w,h)
|
|
gfx.FillColor(255,255,255)
|
|
if (x2-x1) < maxWidth then
|
|
gfx.Text(text,x,y)
|
|
else
|
|
gfx.Text(text,x-ScrollScale,y)
|
|
gfx.FillColor(255,255,0)
|
|
gfx.Text(ScrollScale,x,y-25)
|
|
end
|
|
gfx.ResetScissor()
|
|
|
|
end
|
|
|
|
|
|
function tickScroll(deltaTime)
|
|
if ScrollScale < 630 then
|
|
ScrollScale = ScrollScale + deltaTime *100 -- transition should last for that time in seconds
|
|
else
|
|
ScrollScale = -422
|
|
end
|
|
ScrollOffsetX = 1000 * (1-ScrollScale);
|
|
end
|
|
|
|
|
|
return {
|
|
textmaker = textmaker,
|
|
tickScroll = tickScroll
|
|
}
|
|
|
|
-- * = debug things |