在lua中在屏幕上显示更新的文本



我使用Lua与gideros我在OnEnterFrame方法中有文本更新:

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)

,但这种方式下一个计数只是显示在前一个计数之上。

如果我这样做

self:removeChild(text7),则根本不显示文本。我应该在哪里删除最后的计数,以便只显示更新后的计数?

应该是:

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

然后在ENTER_FRAME事件中:

count = count + 1
text7:setText(count)

最新更新