问题描述
对于HTML5游戏,使用移动设备的画布动画。
我遇到了一些性能问题,它们在每个设备和其他设备之间的速度不同。
requestAnimationFrame 可根据设备速度加快游戏的动画速度。
setInterval 从设备到另一个设备有延迟。
setTimeout 在画布上的绘制也很慢。
以前的移动HTML5游戏的经验可以指导我抛出他们中的三个(或其他技术,如果可用)的最佳方式开发动画在画布上稳定在不同的移动设备上?
如果可能,请始终使用 requestAnimationFrame
。最好是,而不是,因此您不需要处理具体的细节。 / p>
为了使动画或游戏逻辑以相同的速度执行,尽管使用了实际的方法,你应该使用基于时间的动画和基于时间的计算物理等。 p>
For HTML5 games,with canvas animation for mobile devices.
I'm facing some performance issues which differ the speed between each device and the others.
requestAnimationFrame speed the animation of the game according to the device speed.
setInterval shocked me that there are a delay from a device to another.
setTimeout is also slow the drawing on canvas.
Who had a previous experience with Mobile HTML5 games can guide me throw the best way of three of them (or other techniques if available) for developing animation on canvas be stable on different mobile devices ?
Always use requestAnimationFrame
when possible, since that's what it's meant for. It's best to use a shim for support when it isn't, so you don't need to deal with the specific details.
In order for animation or game logic to perform at the same speed despite of actual method used, you should use time based animation and time based calculations for physics or such.
这篇关于setTimeout或setInterval或requestAnimationFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!