refactor(hero): 优化英雄缩放逻辑和位置配置

重构英雄缩放逻辑,使用统一的缩放计算方法替代硬编码值
调整英雄和怪物的初始位置坐标
在Hero和Monster类中添加size变量控制缩放
This commit is contained in:
2025-11-04 10:38:20 +08:00
parent ed1b4f46a4
commit 5c9f299fd7
6 changed files with 55 additions and 38 deletions

View File

@@ -41,7 +41,7 @@ export class Hero extends ecs.Entity {
// console.log("英雄加载:",uuid,pos,scale,info)
scale = 1
// 查找空闲英雄槽位
let size=1
var path = "game/heros/"+HeroInfo[uuid].path;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
@@ -49,6 +49,7 @@ export class Hero extends ecs.Entity {
node.parent = scene.entityLayer!.node!
const collider = node.getComponent(BoxCollider2D);
if (collider) collider.enabled = false; // 先禁用
node.setScale(size*node.scale.x,size*node.scale.y);
node.setPosition(pos)
// 🔥 设置初始 SiblingIndex - 英雄基础层级 + 位置偏移