MainPanel.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { _decorator, Button, Component, director, Node } from 'cc';
  2. import { UIManager } from './UIManager';
  3. import { LoadRes } from '../Config/LoadRes';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('MainPanel')
  6. export class MainPanel extends Component {
  7. @property(Button)
  8. private settingsBtn: Button = null;
  9. @property(Button)
  10. private startBtn: Button = null;
  11. @property(Button)
  12. private inforBtn: Button = null;
  13. @property(Button)
  14. private rankBtn: Button = null;
  15. @property(Button)
  16. private signBtn: Button = null;
  17. start() {
  18. if (director.getScene()?.name === 'Hall') {
  19. this.settingsBtn = this.node.getChildByName('SettingsBtn')?.getComponent(Button);
  20. this.rankBtn = this.node.getChildByPath('Menus/LeftMenu/RankBtn')?.getComponent(Button);
  21. this.inforBtn = this.node.getChildByPath('Menus/RightMenu/InforBtn')?.getComponent(Button);
  22. this.signBtn = this.node.getChildByPath('Menus/LeftMenu/SignBtn')?.getComponent(Button);
  23. this.settingsBtn.node.on(Button.EventType.CLICK, this.settingsPanel, this);
  24. this.rankBtn.node.on(Button.EventType.CLICK, this.rankPanel, this);
  25. this.inforBtn.node.on(Button.EventType.CLICK, this.inforPanel, this);
  26. this.signBtn.node.on(Button.EventType.CLICK, this.signPanel, this);
  27. }
  28. else if(director.getScene()?.name==='Main'){
  29. this.settingsBtn = this.node.getChildByName('SettingsBtn')?.getComponent(Button);
  30. this.settingsBtn.node.on(Button.EventType.CLICK, this.settingsPanel, this);
  31. }
  32. }
  33. update(deltaTime: number) {
  34. }
  35. settingsPanel() {
  36. //设置界面
  37. UIManager.Instance.ShowUI('settingsPanel', LoadRes.getInstance().settingsPanel);
  38. }
  39. rankPanel() {
  40. //排行榜界面
  41. UIManager.Instance.ShowUI('rankPanel', LoadRes.getInstance().rankPanel);
  42. }
  43. inforPanel() {
  44. //个人信息界面
  45. UIManager.Instance.ShowUI('inforPanel', LoadRes.getInstance().inforPanel);
  46. }
  47. signPanel() {
  48. //签到界面
  49. UIManager.Instance.ShowUI('signPanel', LoadRes.getInstance().signPanel);
  50. }
  51. }