求助,在执行如下代码时,按下按键时间过久会导致运动变慢,请问怎么解决:
onKeyDown(event){
if(event.keyCode===cc.macro.KEY.j){
this.bool1=true;
}
if(event.keyCode===cc.macro.KEY.a){
this.goLeftAction.start();
}
else if(event.keyCode===cc.macro.KEY.d){
this.goRightAction.start();
}
},
onKeyUp(event){
if(event.keyCode===cc.macro.KEY.j){
this.bool1=false;
}
if(event.keyCode===cc.macro.KEY.a){
this.goLeftAction.stop();
}
else if(event.keyCode===cc.macro.KEY.d){
this.goRightAction.stop();
}
},
start () {
},
update(dt){
if(this.bool1){
this.delayAction.start();
this.shootBullet();
}
}