【发布时间】:2014-05-08 14:52:46
【问题描述】:
您好,我正在尝试在我的 libgdx 游戏中实现暂停功能,但在暂停每 5 秒发生一次的动画时遇到问题。在我的渲染方法中,我每 5 秒重新启动一次动画。动画完成后,我停止绘制它,它们按预期工作,每 5 秒重新启动和绘制一次。然而,当我按下暂停按钮时,当前动画结束,这没关系,但一旦我取消暂停游戏,它会立即重新绘制另一个动画,而不是等到下一个 5 秒时间段。我认为这是因为一旦我取消暂停,TimeUtils.millis() 仍然大于 5 秒,导致它立即再次触发,所以我将如何重置计时以防止这种情况发生。谢谢。
if(TimeUtils.millis()>=(TimePassed+timekeep.timecheck)&& paused==false)
{ //every N seconds and if not paused
System.out.println("Rendering.....");
stateTime =0; //reset animation
for(int i=0;i<=timekeep.rndy-1;i++){
c.e.get(i).alive=true; //set all characters to alive to be drawn
}
TimePassed = TimeUtils.millis(); //this is the time passed since last restart
}
【问题讨论】:
标签: java android animation libgdx