fix(scenes) 种田系统测试,添加按钮等

This commit is contained in:
wvellichor committed 2026-01-10 05:31:51 +08:00
1 parent ce4e04740a
commit 761a9338ba
19 files changed
+1248 -86

No files matched your search

+37 -14
View File
@@ -153,35 +153,58 @@ export default class ItemTestScene extends Phaser.Scene {
});
this.input.keyboard.on('keydown-TWO', () => {
// 在单位附近创建食物类物品
const x = unit.x + Phaser.Math.Between(-100, 100);
const y = unit.y + Phaser.Math.Between(-100, 100);
this.itemManager.createItemByType('food', x, y);
this.itemManager.createItem('wheat_seed', 0, 0);
});
this.input.keyboard.on('keydown-THREE', () => {
// 在单位附近创建工具类物品
const x = unit.x + Phaser.Math.Between(-100, 100);
const y = unit.y + Phaser.Math.Between(-100, 100);
this.itemManager.createItemByType('tool', x, y);
this.itemManager.createItem('wooden_sword', 0, 0);
});
this.input.keyboard.on('keydown-FOUR', () => {
// 清理所有物品
this.itemManager.clearAllItems();
this.itemInfoText.setText('所有物品已清理');
});
this.input.keyboard.on('keydown-SPACE', () => {
this.scene.start('BootScene');
});
// 监听物品点击事件
this.events.on('item-clicked', (item) => {
this.showItemInfo(item);
// 添加返回菜单按钮
this.createReturnButton();
}
/**
* 创建返回菜单按钮
*/
createReturnButton() {
// 创建按钮背景
const button = this.add.rectangle(10, 250, 150, 40, 0x333333);
button.setOrigin(0, 0);
button.setScrollFactor(0, 0);
button.setDepth(10);
button.setInteractive({ useHandCursor: true });
// 按钮文本
const buttonText = this.add.text(25, 260, '返回菜单', {
fontSize: '16px',
fill: '#ffffff',
fontFamily: 'Arial'
});
buttonText.setScrollFactor(0, 0);
buttonText.setDepth(11);
// 按钮事件
button.on('pointerdown', () => {
this.scene.start('BootScene');
});
// 创建一些交互按钮
this.createButtons();
button.on('pointerover', () => {
button.setFillStyle(0x555555);
});
button.on('pointerout', () => {
button.setFillStyle(0x333333);
});
}
/**