fix(game): 修复格子正方形和图片尺寸问题,用setDisplaySize精确控制角色图片占一格

This commit is contained in:
Cloud Bot
2026-03-21 08:51:56 +00:00
parent 085aa0a407
commit caf9c698c9
5 changed files with 17 additions and 16 deletions

View File

@@ -14,9 +14,9 @@ export class BossVP extends EnemyBase {
) {
super(scene, pathPoints, 800, 40, 30, 150, 'enemy-boss')
this.onDestroyTower = onDestroyTower
// 放大 BOSS
const bossScale = Math.min(this.cellW, this.cellH) / 128 * 1.3
this.imageSprite.setScale(bossScale)
// BOSS 放大到 1.3 个格子(跨格的威压感)
const bossSize = this.cellW * 1.3
this.imageSprite.setDisplaySize(bossSize, bossSize)
this.imageSprite.setDepth(12)
// BOSS 出现特效
scene.cameras.main.flash(800, 255, 0, 0, false)

View File

@@ -87,10 +87,10 @@ export abstract class EnemyBase {
this.y = pathPoints[0].y
}
// 用 AI 图片精灵,尺寸按格子缩放
// 用 AI 图片精灵,精确设为格子尺寸的 75%(怪物比塔小一点)
const enemySize = cellW * 0.75
this.imageSprite = scene.add.image(this.x, this.y, spriteKey)
const scale = Math.min(cellW, cellH) / 128 * 0.75
this.imageSprite.setScale(scale)
this.imageSprite.setDisplaySize(enemySize, enemySize)
this.imageSprite.setDepth(10)
this.healthBar = scene.add.graphics()

View File

@@ -6,9 +6,8 @@ export class OldEmployee extends EnemyBase {
constructor(scene: Phaser.Scene, pathPoints: PathPoint[]) {
super(scene, pathPoints, 150, 50, 8, 30, 'enemy-old')
this.shieldCount = 3
// 老员工图片稍大
const scale = Math.min(this.cellW, this.cellH) / 128 * 0.9
this.imageSprite.setScale(scale)
// 老员工比普通怪略大0.85 个格子)
this.imageSprite.setDisplaySize(this.cellW * 0.85, this.cellW * 0.85)
}
getQuote(): string { return getRandomQuote('OldEmployee') }