移动速度

This commit is contained in:
chenxi 2023-04-20 17:08:27 +08:00
parent aae29468f7
commit a44fb6ca2c
2 changed files with 5 additions and 4 deletions

View File

@ -22,7 +22,8 @@ BattleConst.INIT_POS_X = 140 -- 战斗单位初始化的坐标
BattleConst.UNIT_FRONT_POS_X = 0 -- 战斗单位身前的坐标 BattleConst.UNIT_FRONT_POS_X = 0 -- 战斗单位身前的坐标
BattleConst.UNIT_BODY_WIDTH = 200 BattleConst.UNIT_BODY_WIDTH = 200
BattleConst.UNIT_FRONT_DISTANCE = 50 BattleConst.UNIT_FRONT_DISTANCE = 50
BattleConst.MOVE_SPEED = 2000 -- 战斗单位的移动速度 BattleConst.MOVE_SPEED = 2000 -- 战斗单位攻击时的移动速度
BattleConst.MOVE_SPEED_ENTER = 500 -- 战斗单位入场时的移动速度
BattleConst.HURT_STATE_CRIT = 1 -- 暴击 BattleConst.HURT_STATE_CRIT = 1 -- 暴击
BattleConst.BATTLE_ROUND_STEP = { BattleConst.BATTLE_ROUND_STEP = {

View File

@ -485,7 +485,7 @@ end
function BattleUnitComp:updateEnterBattlefieldState(dt) function BattleUnitComp:updateEnterBattlefieldState(dt)
if self.isMove then if self.isMove then
local addX = dt*BattleConst.MOVE_SPEED*self.moveDirection local addX = dt*BattleConst.MOVE_SPEED_ENTER*self.moveDirection
self.positionX = self.positionX + addX self.positionX = self.positionX + addX
if (self.moveDirection > 0 and self.positionX >= self.targetX) or (self.moveDirection < 0 and self.positionX <= self.targetX) then if (self.moveDirection > 0 and self.positionX >= self.targetX) or (self.moveDirection < 0 and self.positionX <= self.targetX) then
self.isMove = false self.isMove = false
@ -520,7 +520,7 @@ function BattleUnitComp:enterEnterBattlefieldState()
self.targetX = BattleConst.INIT_POS_X self.targetX = BattleConst.INIT_POS_X
self.moveDirection = -1 self.moveDirection = -1
end end
local time = math.abs(self.targetX - self.positionX)/BattleConst.MOVE_SPEED local time = math.abs(self.targetX - self.positionX)/BattleConst.MOVE_SPEED_ENTER
self.battleController:moveBattlefield(time) self.battleController:moveBattlefield(time)
else else
self:playAnimation(SPINE_ANIMATION_NAME.BORN, false, false) self:playAnimation(SPINE_ANIMATION_NAME.BORN, false, false)