feat: 添加页面管理系统和首页/关卡页面
- 实现 ViewManager 单例页面管理器,支持页面注册、打开、关闭、缓存 - 实现 BaseView 页面基类,提供统一的页面生命周期 - 添加 PageHome 首页,包含开始游戏按钮跳转功能 - 添加 PageLevel 关卡页面,继承 BaseView - 更新 PageLoading 支持进度条显示和页面预加载 - 添加相关图片资源和预制体 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,14 +1,40 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
import { _decorator, Component } from 'cc';
|
||||
import { ViewManager } from './scripts/core/ViewManager';
|
||||
const { ccclass } = _decorator;
|
||||
|
||||
/**
|
||||
* 主入口脚本
|
||||
* 负责初始化 ViewManager 并注册页面
|
||||
*/
|
||||
@ccclass('main')
|
||||
export class main extends Component {
|
||||
start() {
|
||||
|
||||
/**
|
||||
* onLoad 比 start 更早执行
|
||||
* 确保 ViewManager 在 PageLoading.start() 之前初始化
|
||||
*/
|
||||
onLoad() {
|
||||
this._initViewManager();
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
/**
|
||||
* 初始化页面管理器
|
||||
*/
|
||||
private _initViewManager(): void {
|
||||
// 初始化 ViewManager,绑定 Canvas 作为页面容器
|
||||
ViewManager.instance.init(this.node);
|
||||
|
||||
// 注册页面配置
|
||||
ViewManager.instance.register('PageHome', {
|
||||
prefabPath: 'prefabs/PageHome',
|
||||
cache: true,
|
||||
zIndex: 0
|
||||
});
|
||||
|
||||
// 注册关卡页面
|
||||
ViewManager.instance.register('PageLevel', {
|
||||
prefabPath: 'prefabs/PageLevel',
|
||||
cache: true,
|
||||
zIndex: 1
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user