feat: 添加页面管理系统和首页/关卡页面

- 实现 ViewManager 单例页面管理器,支持页面注册、打开、关闭、缓存
- 实现 BaseView 页面基类,提供统一的页面生命周期
- 添加 PageHome 首页,包含开始游戏按钮跳转功能
- 添加 PageLevel 关卡页面,继承 BaseView
- 更新 PageLoading 支持进度条显示和页面预加载
- 添加相关图片资源和预制体

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
richarjiang
2026-03-11 10:02:29 +08:00
parent 02a67909d6
commit 8986d8d8f2
29 changed files with 5456 additions and 61 deletions

View File

@@ -1,14 +1,62 @@
import { _decorator, Component, Node } from 'cc';
import { _decorator, Component, ProgressBar } from 'cc';
import { ViewManager } from './scripts/core/ViewManager';
const { ccclass, property } = _decorator;
/**
* 页面加载组件
* 负责预加载资源并显示加载进度
*/
@ccclass('PageLoading')
export class PageLoading extends Component {
start() {
@property(ProgressBar)
progressBar: ProgressBar | null = null;
start() {
this._startPreload();
}
update(deltaTime: number) {
/**
* 开始预加载
*/
private _startPreload(): void {
// 初始化进度条
if (this.progressBar) {
this.progressBar.progress = 0;
}
// 预加载 PageHome
ViewManager.instance.preload('PageHome',
(progress) => {
this._updateProgress(progress);
},
() => {
this._onPreloadComplete();
}
);
}
/**
* 更新进度条
*/
private _updateProgress(progress: number): void {
if (this.progressBar) {
this.progressBar.progress = progress;
}
}
/**
* 预加载完成回调
*/
private _onPreloadComplete(): void {
// 确保进度条显示完成
this._updateProgress(1);
// 打开 PageHome
ViewManager.instance.open('PageHome', {
onComplete: () => {
// PageHome 打开成功后,销毁自身
this.node.destroy();
}
});
}
}