英雄动画重构

This commit is contained in:
2025-10-23 10:43:15 +08:00
parent b0751992f4
commit c1544365ba
211 changed files with 83876 additions and 35746 deletions

View File

@@ -16,8 +16,8 @@ export class move extends Component {
@property({ type: CCInteger })
sc: number = 1; // 1: 从左到右, -1: 从右到左
@property({ type: CCInteger })
isMove:number=0
@property
isMove:boolean=false
protected onLoad(): void {
oops.message.on(GameEvent.MAP_MOVE_END_LEFT, this.onMapMoveEndLeft, this);
oops.message.on(GameEvent.MAP_MOVE_END_RIGHT, this.onMapMoveEndRight, this);
@@ -27,13 +27,13 @@ export class move extends Component {
}
onMapMoveEndLeft() {
if(this.sc==-1){
this.isMove=1
this.isMove=true
this.setInitialPosition()
}
}
onMapMoveEndRight() {
if(this.sc==1){
this.isMove=1
this.isMove=true
this.setInitialPosition()
}
}
@@ -52,7 +52,7 @@ export class move extends Component {
update(dt: number) {
// 更新位置
if(this.isMove==1){
if(this.isMove){
const newX = this.node.position.x + dt * this.speed * this.sc;
this.node.setPosition(newX, this.node.position.y);
// 检查边界并重置位置
@@ -68,14 +68,14 @@ export class move extends Component {
// 从左到右移动,到达右边界后回到左边界
if (this.node.position.x >= this.maxX) {
this.node.setPosition(this.minX, this.node.position.y);
this.isMove=0
this.isMove=false
oops.message.dispatchEvent(GameEvent.MAP_MOVE_END_LEFT)
}
} else if (this.sc < 0) {
// 从右到左移动,到达左边界后回到右边界
if (this.node.position.x <= this.minX) {
this.node.setPosition(this.maxX, this.node.position.y);
this.isMove=0
this.isMove=false
oops.message.dispatchEvent(GameEvent.MAP_MOVE_END_RIGHT)
}
}