请教,为什么在onLoad可以播放的动画在update里卡住了?
var distance=0;
var ani;
cc.Class({
extends: cc.Component,
properties: {
player:cc.Node,
},
onLoad () {
var player=this.player.getPosition();
var self=this.node.getPosition();
this.distance=cc.pDistance(player,self);
this.ani= this.node.getComponent(cc.Animation);
//this.ani.play('nAttack');
},
update (dt) {
if(this.distance>175){
console.log(this.distance+'>175');
this.ani.play('nRun');
}
if(this.distance<175){
//console.log(this.distance+'<175');
this.ani.play('nAttack');
}
},
});
问题解决了,粘贴上来,希望能帮助需要的人