【发布时间】:2019-11-26 01:57:54
【问题描述】:
我的问题是:新圆创建后,动画仍然很快(减少变量动画没有帮助)-> 碰撞发生后如何临时杀死keydown事件监听器,从而无法影响新圆的速度通过第一个会话的空格键?
我正在尝试使用画布和 javascript 制作简单的 game2d。
由于按下空格键,圆圈应该移动得更快(增加动画函数的变量)。 但如果与墙发生碰撞,则应该是游戏结束,那么应该创建新的圆圈。这实际上正在发生。
move(event) {
if (event.keyCode === 65 ) { //left
this.cir.x -= 1
} else if (event.keyCode === 68 ) { //right
this.cir.x += 1
} else if (event.keyCode === 83 ) { //down
if(cir.coll){
this.cir = new cir(1,0);
}
this.cir.x+= 1
} else if (event.key == ' ' ) { // spacebar button
this.dropInterval = 1
if(cir.coll){
this.cir = new cir(1,0) **// for new circle spacebar keydown should be killed temporary so that i should press it again for the new object**
}
}
}
【问题讨论】:
标签: javascript html node.js animation 2d-games