UI_Setting.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { _decorator, Component, Node, Sprite } from 'cc';
  2. import { UIController, UIElement } from 'db://assets/scripts/aa';
  3. import { UI_Dialog } from '../UI_Dialog';
  4. import { rootMgr } from '../../../scene/RootMgr';
  5. import { FMSType } from '../../../GameContorl/fms/FMSGameInit';
  6. const { ccclass, property } = _decorator;
  7. @UIController({ bundleName: 'dialog', path: 'setting/setting' })
  8. export class UI_Setting extends UI_Dialog {
  9. @UIElement(Node)
  10. homeBtn: Node
  11. @UIElement(Node)
  12. rePlayBtn: Node
  13. @UIElement(Node)
  14. mb2: Node
  15. start() {
  16. this.homeBtn.on(Node.EventType.TOUCH_END, this.goHome, this)
  17. this.rePlayBtn.on(Node.EventType.TOUCH_END, this.rePlay, this)
  18. if (rootMgr.game.FMS.CurrentType == FMSType.home) {
  19. this.homeBtn.active = false
  20. this.rePlayBtn.active = false
  21. this.mb2.active = true
  22. this.mb2.parent.position = this.mb2.position.clone().multiplyScalar(-1)
  23. this.Root.getComponent(Sprite).spriteFrame = null
  24. } else {
  25. this.mb2.active = false
  26. }
  27. }
  28. goHome() {
  29. rootMgr.game.Change(FMSType.home)
  30. this.onClose()
  31. }
  32. rePlay() {
  33. rootMgr.game.init()
  34. this.onClose()
  35. }
  36. }