角色 停止后 切换到idle动画
This commit is contained in:
@@ -28,26 +28,35 @@ export class BattleMoveSystem extends ecs.ComblockSystem implements ecs.ISystemU
|
||||
|
||||
// 同步状态
|
||||
|
||||
if (!shouldStop) { //在攻击范围内停止移动 取消这个判断
|
||||
if (!shouldStop) { //在攻击范围内停止移动
|
||||
// if(view.fac==1){
|
||||
if(view.is_stop||view.is_dead||view.DEBUFF_STUN>0 ||view.DEBUFF_FROST>0) return //停止移动或者死亡不移动
|
||||
if(view.is_stop||view.is_dead||view.DEBUFF_STUN>0 ||view.DEBUFF_FROST>0) {
|
||||
view.status_change("idle");
|
||||
return; //停止移动或者死亡不移动
|
||||
}
|
||||
// 新增墓地位置判断,如果已经在墓地则不再移动
|
||||
if (view.node.position.x === -1000 || view.node.position.x === 1000) {
|
||||
view.status_change("idle");
|
||||
return;
|
||||
}
|
||||
// 计算移动量
|
||||
const delta = ((view.speed-view.DEBUFF_SLOW)/3) * this.dt * move.direction;
|
||||
const newX = view.node.position.x + delta;
|
||||
|
||||
view.status_change("move")
|
||||
|
||||
// 限制移动范围
|
||||
if (this.validatePosition(newX, move)) {
|
||||
view.status_change("move");
|
||||
view.node.setPosition(newX, view.node.position.y, 0);
|
||||
} else {
|
||||
// 当达到目标位置边界时也切换为idle状态
|
||||
view.status_change("idle");
|
||||
// 达到边界是永久停止,设置moving为false
|
||||
move.moving = false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
view.status_change("idle")
|
||||
view.status_change("idle");
|
||||
// 因为敌人在面前而暂时停止,不设置moving为false,保持检查状态
|
||||
}
|
||||
this.checkEnemiesInBase(e)
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ export default class HeroAnmComp extends Component{
|
||||
if (this._hasStop) {
|
||||
this.spine?.setToSetupPose();
|
||||
}
|
||||
// console.log("do move",this.spine?.animation);
|
||||
this.spine?.setAnimation(0, 'Walking', true);
|
||||
this.default_anim='Walking'
|
||||
this._hasStop = false;
|
||||
@@ -105,6 +106,8 @@ export default class HeroAnmComp extends Component{
|
||||
}
|
||||
idle () {
|
||||
this.spine?.setToSetupPose();
|
||||
if(this.spine?.animation==='Idle') return
|
||||
// console.log("do idle",this.spine.animation);
|
||||
this.spine?.setAnimation(0, 'Idle', true);
|
||||
this.default_anim='Idle'
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export class HeroSpine extends Component {
|
||||
@property(HeroAnmComp)
|
||||
anm: HeroAnmComp = null;
|
||||
|
||||
status:string="Idle";
|
||||
status:string="idle";
|
||||
|
||||
onLoad() {
|
||||
// 角色控制组件
|
||||
@@ -36,9 +36,10 @@ export class HeroSpine extends Component {
|
||||
|
||||
}
|
||||
idle(){
|
||||
// console.log("change to idle",this.status);
|
||||
// console.log("do Idle");
|
||||
if(this.status=="Idle") return
|
||||
this.status="Idle"
|
||||
if(this.status=="idle") return
|
||||
this.status="idle"
|
||||
this.anm.idle()
|
||||
}
|
||||
atk() {
|
||||
@@ -67,7 +68,7 @@ export class HeroSpine extends Component {
|
||||
}
|
||||
|
||||
move(){
|
||||
// console.log("doing move");
|
||||
// console.log("change to move",this.status);
|
||||
if(this.status=="move") return
|
||||
this.status="move"
|
||||
this.anm.move()
|
||||
|
||||
Reference in New Issue
Block a user