From d21f59cafa98663aa94c468af8babf3c6ff072ec Mon Sep 17 00:00:00 2001 From: genxium Date: Sun, 20 Nov 2022 21:07:45 +0800 Subject: [PATCH] Minor fix. --- frontend/assets/scenes/login.fire | 2 +- frontend/assets/scenes/offline_map_1.fire | 2 +- frontend/assets/scripts/AttackingCharacter.js | 19 +++++++++---------- frontend/assets/scripts/BaseCharacter.js | 8 ++------ .../assets/scripts/ControlledCharacter.js | 3 --- frontend/assets/scripts/Map.js | 4 +--- frontend/assets/scripts/OfflineMap.js | 2 +- 7 files changed, 15 insertions(+), 25 deletions(-) diff --git a/frontend/assets/scenes/login.fire b/frontend/assets/scenes/login.fire index 87ea411..76a6bfa 100644 --- a/frontend/assets/scenes/login.fire +++ b/frontend/assets/scenes/login.fire @@ -440,7 +440,7 @@ "array": [ 0, 0, - 239.32248305180272, + 216.50635094610968, 0, 0, 0, diff --git a/frontend/assets/scenes/offline_map_1.fire b/frontend/assets/scenes/offline_map_1.fire index 249cb54..4939b21 100644 --- a/frontend/assets/scenes/offline_map_1.fire +++ b/frontend/assets/scenes/offline_map_1.fire @@ -453,7 +453,7 @@ "array": [ 0, 0, - 239.32248305180272, + 216.50635094610968, 0, 0, 0, diff --git a/frontend/assets/scripts/AttackingCharacter.js b/frontend/assets/scripts/AttackingCharacter.js index 7bfbc34..6340bdf 100644 --- a/frontend/assets/scripts/AttackingCharacter.js +++ b/frontend/assets/scripts/AttackingCharacter.js @@ -6,6 +6,11 @@ window.ATK_CHARACTER_STATE = { Atk1: [2, "Atk1"], }; +window.ATK_CHARACTER_STATE_ARR = []; +for (let k in window.ATK_CHARACTER_STATE) { + window.ATK_CHARACTER_STATE_ARR.push(window.ATK_CHARACTER_STATE[k]); +} + cc.Class({ extends: BaseCharacter, properties: { @@ -44,17 +49,11 @@ cc.Class({ } if (newCharacterState != this.characterState) { - switch (newCharacterState) { - case ATK_CHARACTER_STATE.Idle1[0]: - this.animComp.playAnimation(ATK_CHARACTER_STATE.Idle1[1]); - break; - case ATK_CHARACTER_STATE.Walking[0]: - this.animComp.playAnimation(ATK_CHARACTER_STATE.Walking[1]); - break; - default: - break; - } this.characterState = newCharacterState; + const newAnimName = window.ATK_CHARACTER_STATE_ARR[newCharacterState][1]; + if (newAnimName != this.animComp.animationName) { + this.animComp.playAnimation(newAnimName); + } } }, }); diff --git a/frontend/assets/scripts/BaseCharacter.js b/frontend/assets/scripts/BaseCharacter.js index 1ae2e19..3d4cf93 100644 --- a/frontend/assets/scripts/BaseCharacter.js +++ b/frontend/assets/scripts/BaseCharacter.js @@ -8,17 +8,13 @@ module.export = cc.Class({ } }, - // LIFE-CYCLE CALLBACKS: - start() { - const self = this; - self.activeDirection = { + ctor() { + this.activeDirection = { dx: 0, dy: 0 }; }, - ctor() {}, - onLoad() { const self = this; const canvasNode = self.mapNode.parent; diff --git a/frontend/assets/scripts/ControlledCharacter.js b/frontend/assets/scripts/ControlledCharacter.js index 5cb5211..9e7988a 100644 --- a/frontend/assets/scripts/ControlledCharacter.js +++ b/frontend/assets/scripts/ControlledCharacter.js @@ -12,9 +12,6 @@ cc.Class({ default: null } }, - start() { - AttackingCharacter.prototype.start.call(this); - }, onLoad() { AttackingCharacter.prototype.onLoad.call(this); diff --git a/frontend/assets/scripts/Map.js b/frontend/assets/scripts/Map.js index c63da11..4f7f070 100644 --- a/frontend/assets/scripts/Map.js +++ b/frontend/assets/scripts/Map.js @@ -976,14 +976,12 @@ cc.Class({ const wpos = self.virtualGridToWorldPos(immediatePlayerInfo.virtualGridX, immediatePlayerInfo.virtualGridY); const dx = (wpos[0] - playerRichInfo.node.x); const dy = (wpos[1] - playerRichInfo.node.y); - const justJiggling = (self.jigglingEps1D >= Math.abs(dx) && self.jigglingEps1D >= Math.abs(dy)); - //if (!justJiggling) { + //const justJiggling = (self.jigglingEps1D >= Math.abs(dx) && self.jigglingEps1D >= Math.abs(dy)); playerRichInfo.node.setPosition(wpos[0], wpos[1]); playerRichInfo.virtualGridX = immediatePlayerInfo.virtualGridX; playerRichInfo.virtualGridY = immediatePlayerInfo.virtualGridY; playerRichInfo.scriptIns.scheduleNewDirection(immediatePlayerInfo.dir, false); playerRichInfo.scriptIns.updateSpeed(immediatePlayerInfo.speed); - //} }); }, diff --git a/frontend/assets/scripts/OfflineMap.js b/frontend/assets/scripts/OfflineMap.js index 3d38324..a424d0a 100644 --- a/frontend/assets/scripts/OfflineMap.js +++ b/frontend/assets/scripts/OfflineMap.js @@ -149,7 +149,7 @@ cc.Class({ players: { 10: { id: 10, - joinIndex: 2, + joinIndex: 1, virtualGridX: 0, virtualGridY: 0, speed: 2 * self.worldToVirtualGridRatio,