Issue:
Issues with fps when displaying this particular text block (others work fine).
What I've tried:
I tried isolating each part (removing timers, removing rectangles, removing text), but it always seems to make the game run more slowly. I've optimized the timers and put the text into sprites.
Question:
Is there anything that looks a bit off here? Thank you!
Code snippet:
class('LargeText').extends(gfx.sprite)
function LargeText:init(x,y,textString)
local textSprite = gfx.sprite.new()
textSprite.currentText= textString
textSprite:setSize(280, 60)
textSprite:setCenter(0, 0)
textSprite:moveTo(x, y)
textSprite:setZIndex(899)
textSprite:setIgnoresDrawOffset(true)
local killTextTimer = pd.timer.new(5000)
function textSprite:draw()
gfx.pushContext()
gfx.setFont(font)
gfx.setColor(gfx.kColorWhite)
gfx.fillRoundRect(1,1,229,60,8)
gfx.setColor(gfx.kColorBlack)
gfx.drawRoundRect(0,0,230,60,8)
gfx.setImageDrawMode(gfx.kDrawModeFillBlack)
gfx.drawTextInRect(self.currentText, 12, 12, 230, 60)
gfx.popContext()
end
function textSprite:update()
killTextTimer.timerEndedCallback = function()
self:remove()
end
end
textSprite:add()
end
Sampler: