mirror of
http://junepve.top:3000/chicrobot/CINC.git
synced 2026-10-30 07:41:29 +08:00
fix(CATS) 修复角色动画与原点问题
This commit is contained in:
1 parent
f6f7076fcb
commit
683803945a
2 files changed
+45
-24
No files matched your search
+15
-1
@@ -5,6 +5,12 @@ export default class Unit extends Phaser.Physics.Arcade.Sprite {
|
||||
scene.add.existing(this);
|
||||
scene.physics.add.existing(this);
|
||||
|
||||
// 设置角色原点为底部中点
|
||||
this.setOrigin(0.5, 1);
|
||||
|
||||
// 设置角色深度,确保显示在指示器上方
|
||||
this.setDepth(10);
|
||||
|
||||
// 启用圆形碰撞体(更自然)
|
||||
this.setCircle(14);
|
||||
|
||||
@@ -32,7 +38,8 @@ export default class Unit extends Phaser.Physics.Arcade.Sprite {
|
||||
*/
|
||||
createSelectedIndicator() {
|
||||
// 创建一个外圈指示器,默认隐藏
|
||||
this.selectedIndicator = this.scene.add.circle(this.x, this.y, this.width * 0.7, 0x00ff00, 0.0);
|
||||
// 椭圆指示器:中心位于图片底边中心,宽度为角色宽度的1.4倍,高度为角色高度的0.3倍
|
||||
this.selectedIndicator = this.scene.add.ellipse(this.x, this.y, this.width * 1.5, this.height * 0.5, 0x00ff00, 0.0);
|
||||
this.selectedIndicator.setStrokeStyle(2, 0x00ff00, 1);
|
||||
this.selectedIndicator.setVisible(false);
|
||||
|
||||
@@ -40,6 +47,8 @@ export default class Unit extends Phaser.Physics.Arcade.Sprite {
|
||||
this.selectedIndicator.setOrigin(0.5, 0.5);
|
||||
// 移除固定位置设置,让指示器随单位和相机一起移动
|
||||
this.selectedIndicator.setScrollFactor(1, 1);
|
||||
// 设置较低的深度,确保角色显示在上方
|
||||
this.selectedIndicator.setDepth(5);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,6 +61,8 @@ export default class Unit extends Phaser.Physics.Arcade.Sprite {
|
||||
this.targetIndicator.setOrigin(0.5, 0.5);
|
||||
this.targetIndicator.setScrollFactor(1, 1);
|
||||
this.targetIndicator.setVisible(false);
|
||||
// 设置较低的深度,确保角色显示在上方
|
||||
this.targetIndicator.setDepth(5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +74,8 @@ export default class Unit extends Phaser.Physics.Arcade.Sprite {
|
||||
// 创建图形对象用于绘制路径
|
||||
this.pathGraphics = this.scene.add.graphics();
|
||||
this.pathGraphics.setScrollFactor(1, 1);
|
||||
// 设置较低的深度,确保角色显示在上方
|
||||
this.pathGraphics.setDepth(5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,6 +202,7 @@ export default class Unit extends Phaser.Physics.Arcade.Sprite {
|
||||
update() {
|
||||
// 更新选中指示器位置
|
||||
if (this.selectedIndicator && this.isSelected) {
|
||||
// 保持与创建时相同的位置偏移,确保指示器显示在角色底部
|
||||
this.selectedIndicator.setPosition(this.x, this.y);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user