import { _decorator, Button, Component, director, Node } from 'cc'; import { UIManager } from './UIManager'; import { LoadRes } from '../Config/LoadRes'; const { ccclass, property } = _decorator; @ccclass('MainPanel') export class MainPanel extends Component { @property(Button) private settingsBtn: Button = null; @property(Button) private startBtn: Button = null; @property(Button) private inforBtn: Button = null; @property(Button) private rankBtn: Button = null; @property(Button) private signBtn: Button = null; start() { if (director.getScene()?.name === 'Hall') { this.settingsBtn = this.node.getChildByName('SettingsBtn')?.getComponent(Button); this.rankBtn = this.node.getChildByPath('Menus/LeftMenu/RankBtn')?.getComponent(Button); this.inforBtn = this.node.getChildByPath('Menus/RightMenu/InforBtn')?.getComponent(Button); this.signBtn = this.node.getChildByPath('Menus/LeftMenu/SignBtn')?.getComponent(Button); this.settingsBtn.node.on(Button.EventType.CLICK, this.settingsPanel, this); this.rankBtn.node.on(Button.EventType.CLICK, this.rankPanel, this); this.inforBtn.node.on(Button.EventType.CLICK, this.inforPanel, this); this.signBtn.node.on(Button.EventType.CLICK, this.signPanel, this); } else if(director.getScene()?.name==='Main'){ this.settingsBtn = this.node.getChildByName('SettingsBtn')?.getComponent(Button); this.settingsBtn.node.on(Button.EventType.CLICK, this.settingsPanel, this); } } update(deltaTime: number) { } settingsPanel() { //设置界面 UIManager.Instance.ShowUI('settingsPanel', LoadRes.getInstance().settingsPanel); } rankPanel() { //排行榜界面 UIManager.Instance.ShowUI('rankPanel', LoadRes.getInstance().rankPanel); } inforPanel() { //个人信息界面 UIManager.Instance.ShowUI('inforPanel', LoadRes.getInstance().inforPanel); } signPanel() { //签到界面 UIManager.Instance.ShowUI('signPanel', LoadRes.getInstance().signPanel); } }