在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),文本就根本不会显示。我应该在哪里移除上一个计数,以便仅显示更新的计数?

点赞
用户2274511
用户2274511

应该这样:

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)
2014-10-01 17:57:43