fix: update button to choose cat

This commit is contained in:
hypercross 2026-04-05 00:06:48 +08:00
parent 449727d650
commit 6ebfcc6c4d
1 changed files with 17 additions and 0 deletions

View File

@ -44,6 +44,8 @@ export class PieceTypeSelector {
bg.setInteractive({ useHandCursor: true }); bg.setInteractive({ useHandCursor: true });
bg.on('pointerdown', () => { bg.on('pointerdown', () => {
this.selectedType = type; this.selectedType = type;
// 立即更新按钮高亮状态
this.updateButtonsVisual();
this.typeChangeCallback?.(this.selectedType); this.typeChangeCallback?.(this.selectedType);
}); });
@ -54,6 +56,21 @@ export class PieceTypeSelector {
this.typeChangeCallback = callback; this.typeChangeCallback = callback;
} }
/**
*
*/
private updateButtonsVisual(): void {
const kittenBg = this.kittenButton.list[0] as Phaser.GameObjects.Rectangle;
const kittenText = this.kittenButton.list[1] as Phaser.GameObjects.Text;
const catBg = this.catButton.list[0] as Phaser.GameObjects.Rectangle;
const catText = this.catButton.list[1] as Phaser.GameObjects.Text;
// 更新小猫按钮
kittenBg.setFillStyle(this.selectedType === 'kitten' ? 0xfbbf24 : 0xe5e7eb);
// 更新大猫按钮
catBg.setFillStyle(this.selectedType === 'cat' ? 0xfbbf24 : 0xe5e7eb);
}
getSelectedType(): PieceType { getSelectedType(): PieceType {
return this.selectedType; return this.selectedType;
} }