UI_HUD.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { profiler } from "cc";
  2. import { Layout_UI_HUD } from "./Layout_HUD";
  3. import { tgxUIMgr, tgxUIController } from "../../core_tgx/tgx";
  4. import { GameUILayers } from "../../scripts/GameUILayers";
  5. import { UI_AboutMe } from "../../scripts/UIDef";
  6. export class UI_HUD extends tgxUIController {
  7. constructor() {
  8. super('ui_hud/UI_HUD', GameUILayers.HUD, Layout_UI_HUD);
  9. }
  10. public getRes(): [] {
  11. return [];
  12. }
  13. //子类的所有操作,需要在这个函数之后。
  14. protected onCreated() {
  15. let layout = this.layout as Layout_UI_HUD;
  16. this.onButtonEvent(layout.btnScenes, this.onSceneChange, this);
  17. this.onButtonEvent(layout.btnToggleStats, this.onToggleStats, this);
  18. this.onButtonEvent(layout.btnAbout, () => {
  19. tgxUIMgr.inst.showUI(UI_AboutMe);
  20. });
  21. }
  22. onToggleStats() {
  23. if (profiler.isShowingStats()) {
  24. profiler.hideStats();
  25. }
  26. else {
  27. profiler.showStats();
  28. }
  29. }
  30. onSceneChange() {
  31. // tgxUIMgr.inst.showUI(UI_DemoList, (ui: UI_DemoList) => {
  32. // ui.showCloseBtn();
  33. // });
  34. }
  35. //销毁
  36. protected onDispose() {
  37. }
  38. //
  39. protected onUpdate() {
  40. }
  41. }