Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
TextField with custom font causing lag — Gideros Forum

TextField with custom font causing lag

edited July 2012 in General questions
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:setText("00")
scoreLabel:setPosition(5, scoreLabel:getHeight() + 5)
self:addChild(scoreLabel)
Then, in the game loop I set the score like this:
scoreLabel:setText(self.score)
where score is a number amount. Does anything look wrong or should be done differently?

Thanks
Wuji Touch Software
http://wujitouch.com

Comments

Sign In or Register to comment.