fix(game): 修复格子正方形和图片尺寸问题,用setDisplaySize精确控制角色图片占一格
This commit is contained in:
@@ -56,10 +56,10 @@ export abstract class TowerBase {
|
||||
this.px = gridX * cellW + cellW / 2
|
||||
this.py = HUD_HEIGHT + gridY * cellH + cellH / 2
|
||||
|
||||
// 用 AI 图片作为精灵
|
||||
// 用 AI 图片作为精灵,精确设为格子尺寸的 85%(留边距)
|
||||
const imgSize = cellW * 0.85
|
||||
this.imageSprite = scene.add.image(this.px, this.py, spriteKey)
|
||||
const scale = Math.min(cellW, cellH) / 128 * 0.85
|
||||
this.imageSprite.setScale(scale)
|
||||
this.imageSprite.setDisplaySize(imgSize, imgSize)
|
||||
this.imageSprite.setDepth(10)
|
||||
|
||||
this.staminaBar = scene.add.graphics()
|
||||
|
||||
Reference in New Issue
Block a user