Display updated text on screen in lua

397 Views Asked by At

I am using Lua with gideros I have the text updating in OnEnterFrame method:

count = count + 1
text7 = TextField.new(conf.fontchange, count)
text7:setPosition(conf.dx - conf.width/3, conf.dy - conf.height/3)
text7:setTextColor(0x000ff)
self:addChild(text7)

but this way the next count is just displayed over the earlier one.

If I do

self:removeChild(text7) , the text is not displayed at all. Where should I be removing the last count so that only the updated count is displayed?

1

There are 1 best solutions below

0
Artūrs Sosins On

It should be:

text7 = TextField.new(conf.fontchange, count)
text7:setPosition(conf.dx - conf.width/3, conf.dy - conf.height/3)
text7:setTextColor(0x000ff)
self:addChild(text7)

And then later inside ENTER_FRAME event:

count = count + 1
text7:setText(count)