如果有人熟悉knife.timer on Lua,请您看看我的代码,告诉我有什么问题吗?
我希望做两件事:
使用下面的代码,我的倒计时计时器从9开始,但很好地进入了负10。我的角色在4秒后开始眨眼,在改变状态后继续闪烁几秒钟。
我主要有Timer:update(dt),所以我不知道为什么时间不确定。我认为在字符闪烁16次之前,finish不会调用change状态函数。
function PlayerPilotState:update(dt)
self.player.currentAnimation:update(dt)
Timer.every(1, function()
self.timer = self.timer - 1
end)
Timer.after(6, function()
Timer.every(0.2, function()
self.player.blinking = not self.player.blinking
self.player.otherPlayer.blinking = not self.player.otherPlayer.blinking
end):finish(function()
self.player:changeState('falling')
self.player.otherPlayer:changeState('falling')
end):limit(16)
end)
end谢谢!
发布于 2020-08-25 14:01:08
使用基本倒计时计时器的
self.timer = math.max(0,self.timer - 1)或:limit(9)
2.由于使用了Timer.after,您是否对它进行了适当的计时(很难感觉到已经过去了多少时间)。:finish()函数发生在:after()内部和:every()之后,这可能导致事情变得很奇怪。我建议在:limit之前添加:finish()。
Timer.after(6, function()
Timer.every(0.2, function()
self.player.blinking = not self.player.blinking
self.player.otherPlayer.blinking = not self.player.otherPlayer.blinking
end):limit(16):finish(function()
self.player:changeState('falling')
self.player.otherPlayer:changeState('falling')
end)
end)https://stackoverflow.com/questions/63571456
复制相似问题