I have a textfield for my score counter and if I call setText("XXX") each frame to update the score the frame rate drops a lot if I have about 15-20 moving sprites on the screen. I also noticed in Xcode it shows these two messages whenever setText is called:
log: Inserting *unnamed* to the texture cache. Total memory is 9804 KB.
log: Deleting *unnamed* from the texture memory. Total memory is 9796 KB.
I've tried setting the text every 5 or 10 frames and that does seem to help but the score doesn't update as much as I'd like it to.
I initialize the TextField like this inside of a scene:
local font = TTFont.new("fonts/Averia-Regular.ttf", 28)
scoreLabel = TextField.new(font)
scoreLabel:setPosition(5, scoreLabel:getHeight() + 5)
Then, in the game loop I set the score like this:
where score is a number amount. Does anything look wrong or should be done differently?