mirror of
http://junepve.top:3000/chicrobot/CINC.git
synced 2026-10-29 21:31:29 +08:00
feat(item) 优化移动及添加测试场景
This commit is contained in:
1 parent
2f7210f47e
commit
b9a5180293
15 files changed
+1428
-62
No files matched your search
@@ -0,0 +1,80 @@
|
||||
// 启动场景:用于选择进入不同的测试场景
|
||||
import GameScene from './GameScene.js';
|
||||
|
||||
export default class BootScene extends Phaser.Scene {
|
||||
constructor() {
|
||||
super({ key: 'BootScene' });
|
||||
}
|
||||
|
||||
create() {
|
||||
// 设置背景色
|
||||
this.cameras.main.setBackgroundColor('#000000');
|
||||
|
||||
// 添加标题文本
|
||||
this.add.text(this.sys.game.config.width / 2, 100, '测试场景菜单', {
|
||||
fontSize: '32px',
|
||||
fill: '#ffffff',
|
||||
fontFamily: 'Arial'
|
||||
}).setOrigin(0.5, 0.5);
|
||||
|
||||
// 测试场景列表
|
||||
const testScenes = [
|
||||
{ key: 'MovementTestScene1', name: '测试场景1:相对移动(键盘控制)' },
|
||||
{ key: 'MovementTestScene2', name: '测试场景2:目标点移动' },
|
||||
{ key: 'MovementTestScene3', name: '测试场景3:单位选择与移动命令' },
|
||||
{ key: 'MovementTestScene4', name: '测试场景4:虚拟摇杆控制' },
|
||||
{ key: 'MovementTestScene5', name: '测试场景5:移动更新逻辑' },
|
||||
{ key: 'MovementTestScene6', name: '测试场景6:小地图测试' },
|
||||
{ key: 'ItemTestScene', name: '测试场景7:物品系统测试' },
|
||||
{ key: 'GameScene', name: '返回主游戏场景' }
|
||||
];
|
||||
|
||||
// 创建按钮网格
|
||||
const buttonWidth = 400;
|
||||
const buttonHeight = 50;
|
||||
const buttonSpacing = 20;
|
||||
const startY = 200;
|
||||
|
||||
testScenes.forEach((scene, index) => {
|
||||
// 创建按钮背景
|
||||
const button = this.add.rectangle(
|
||||
this.sys.game.config.width / 2,
|
||||
startY + index * (buttonHeight + buttonSpacing),
|
||||
buttonWidth,
|
||||
buttonHeight,
|
||||
0x333333
|
||||
).setOrigin(0.5, 0.5);
|
||||
|
||||
// 添加按钮文本
|
||||
const text = this.add.text(
|
||||
this.sys.game.config.width / 2,
|
||||
startY + index * (buttonHeight + buttonSpacing),
|
||||
scene.name,
|
||||
{
|
||||
fontSize: '18px',
|
||||
fill: '#ffffff',
|
||||
fontFamily: 'Arial'
|
||||
}
|
||||
).setOrigin(0.5, 0.5);
|
||||
|
||||
// 使按钮可交互
|
||||
button.setInteractive({
|
||||
useHandCursor: true
|
||||
});
|
||||
|
||||
// 添加点击事件
|
||||
button.on('pointerdown', () => {
|
||||
this.scene.start(scene.key);
|
||||
});
|
||||
|
||||
// 添加悬停效果
|
||||
button.on('pointerover', () => {
|
||||
button.setFillStyle(0x555555);
|
||||
});
|
||||
|
||||
button.on('pointerout', () => {
|
||||
button.setFillStyle(0x333333);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user