我是一名新手游戏开发人员,我遇到了一个我正在尝试处理的问题。我正在使用 JAVA 开发 Android 游戏。
情况是我正在使用 deltaTime 在任何设备中进行平滑运动等,但我遇到了一个问题。在游戏的特定时刻,它实现了一个非常昂贵的操作,该操作会增加下一次迭代的 deltaTime。有了这个,下一次迭代会有点滞后,并且在旧的慢速设备中可能会非常糟糕。
为了解决这个问题,我想出了一个解决方案,我想与您分享,并对可能发生的情况提供一些反馈。算法如下:
1) Every iteration, the deltatime is added to an "average deltatime variable" which keeps an average of all the iterations
2) If in an iteration the deltaTime is at least twice the value of the "average variable", then I reasign its value to the average
有了这个,游戏将适应设备的实际性能,并且不会在具体迭代中滞后。
你怎么看?我只是编造的,我想更多的人遇到了这个问题,还有另一个更好的解决方案......需要提示!谢谢