fix(SMoveSystem): 修复线性移动的起始与目标位置计算错误
修正线性移动类型中位置调整逻辑,现在正确基于 startPos 和 targetPos 应用 atk_x 和 atk_y 偏移量,而非错误地使用 node.position。同时确保水平移动开关能正确对齐起始与目标的 Y 轴坐标。
This commit is contained in:
@@ -65,18 +65,24 @@ export class SMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
switch(moveComp.runType) {
|
||||
case RType.linear:
|
||||
// linear类型:根据atk_x和atk_y调整位置
|
||||
const linearPos = v3(
|
||||
node.position.x + moveComp.atk_x,
|
||||
node.position.y + moveComp.atk_y,
|
||||
node.position.z
|
||||
const adjustedStartPos = v3(
|
||||
moveComp.startPos.x + moveComp.atk_x,
|
||||
moveComp.startPos.y + moveComp.atk_y,
|
||||
moveComp.startPos.z
|
||||
);
|
||||
const adjustedTargetPos = v3(
|
||||
moveComp.targetPos.x + moveComp.atk_x,
|
||||
moveComp.targetPos.y + moveComp.atk_y,
|
||||
moveComp.targetPos.z
|
||||
);
|
||||
|
||||
// 如果开启水平移动开关,强制目标Y等于起点Y
|
||||
if (moveComp.isHorizontal) {
|
||||
moveComp.targetPos.y = linearPos.y;
|
||||
adjustedTargetPos.y = adjustedStartPos.y;
|
||||
}
|
||||
|
||||
moveComp.rePos(linearPos);
|
||||
moveComp.startPos.set(adjustedStartPos);
|
||||
moveComp.targetPos.set(adjustedTargetPos);
|
||||
node.setPosition(adjustedStartPos);
|
||||
|
||||
// 设置旋转角度
|
||||
const direction = new Vec3();
|
||||
@@ -96,7 +102,9 @@ export class SMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
// 固定结束位置
|
||||
node.setPosition(moveComp.targetPos.x > 360 ? 300 : moveComp.targetPos.x, node.position.y, 0);
|
||||
break;
|
||||
|
||||
case RType.bezier:
|
||||
//
|
||||
return
|
||||
default:
|
||||
// 其他类型(包括bezier):根据atk_x和atk_y调整起始位置
|
||||
if (moveComp.atk_x !== 0 || moveComp.atk_y !== 0) {
|
||||
|
||||
Reference in New Issue
Block a user