请教大佬们
想实现通过AD键控制角色行走,并在行走过程中播放行走动画。动画循环播放后要怎样在松开按键的时候停止动画呢?我直接加
this.anim.stop(‘walk’);
出现一松开按键之后就卡在某一帧的情况
希望能有大佬教教我
onKeyUp: function (event) {
if(event.keyCode === this.moveDirection){
this.moveDirection = null;
}
},
update:function(dt){
switch(this.moveDirection){
case cc.macro.KEY.a:
this.node.x -= this.speed;
break;
case cc.macro.KEY.d:
this.node.x += this.speed;
break;
}
}
});