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

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 10:02:29 +08:00

41 lines
1021 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { _decorator, Component } from 'cc';
import { ViewManager } from './scripts/core/ViewManager';
const { ccclass } = _decorator;
/**
* 主入口脚本
* 负责初始化 ViewManager 并注册页面
*/
@ccclass('main')
export class main extends Component {
/**
* onLoad 比 start 更早执行
* 确保 ViewManager 在 PageLoading.start() 之前初始化
*/
onLoad() {
this._initViewManager();
}
/**
* 初始化页面管理器
*/
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
});
}
}