123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import { EventType, ObserverManager } from './Manager/core/EventManager';
- import PrefabManager from './Manager/core/PrefabManager';
- import { UIID } from './Manager/core/UIID';
- import { gameModel } from './Module/Module';
- import CCUtils from './Utiles/CCUtils';
- import Utiles from './Utiles/Utiles';
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class Main extends cc.Component {
- public windowsLayer: cc.Node = null;
- start() {}
- protected onLoad(): void {}
- /**
- * 初始化
- *
- * @protected
- * @memberof Main
- */
- protected onEnable(): void {
- this.windowsLayer = CCUtils.findChild(this.node, 'windowsLayer');
- // 打开主界面
- PrefabManager.open(UIID.MainHome, this.windowsLayer);
- PrefabManager.open(UIID.GameMainPrefab, this.windowsLayer, (node: cc.Node) => {
- PrefabManager.close(node);
- });
- // 加载BGM
- // 监听管理类
- this.eventManager();
- }
- private eventManager(): void {
- // 打开游戏界面
- ObserverManager.addObserver(EventType.OpenGame, (data): void => {
- this.openGame(data);
- });
- }
- private openGame(data?: any): any {
- // 打开游戏界面 data.index 表示第几首歌
- gameModel.curIndex = data.index;
- console.log('打开游戏界面', gameModel.curIndex);
- PrefabManager.close(UIID.MainHome);
- PrefabManager.open(UIID.GameMainPrefab, this.windowsLayer);
- }
- }
|