我如何在一定时间内开始动画?
我的程序的主要循环是使用requestAnimationframe循环的,例如角色崩溃后,为他碰撞3秒钟,然后以相同的速度眨眼?同时,整个游戏玩法将继续以不同的速度动画,
如何以不同的速度和一个动画中的时间来运行另一个动画?
我认为这里不需要的代码,使用requestAnimationFrame:
function loop() {
requestAnimationFrame(loop)
let now = new Date().getTime(),
dt = now - (time || now)
time = now
game.step(dt)
game.render()
}
谢谢
I have the main loop of the program looped using requestAnimationFrame As for example after the character crashed, disable the collision for him for 3 seconds and blink at the same speed? At the same time, the entire gameplay will continue to animate at a different speed
How can I run another animation at a different speed and for a time during one animation?
The code I think is not required here, a standard animation loop using requestAnimationFrame:
function loop() {
requestAnimationFrame(loop)
let now = new Date().getTime(),
dt = now - (time || now)
time = now
game.step(dt)
game.render()
}
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

您需要分别为每个动画存储“计时器”,然后添加会触发某些动画的条件(字符崩溃了吗?
You'll need store "timers" for each animation separately, then add conditions that would trigger certain animations (is character crashed? -> animate1, if animate1 is currently running -> animate2, etc)