UI_Lose.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { _decorator, Component, Node, UI } 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. import { rotate_anim_ext, rotate_anim_stop } from '../../../util/Customize_Ani';
  7. import { BgmName } from 'db://assets/scripts/Audio/BgmName';
  8. import { audioManager } from 'db://assets/scripts/Audio/AudioManager';
  9. const { ccclass, property } = _decorator;
  10. @UIController({ bundleName: 'dialog', path: 'lose/lose' })
  11. @ccclass('UI_Lose')
  12. export class UI_Lose extends UI_Dialog {
  13. //@UIElement({type: Node,prefix:"__"})
  14. @UIElement(Node)
  15. returnBtn: Node;
  16. @UIElement(Node)
  17. againBtn: Node;
  18. @UIElement(Node)
  19. light: Node;
  20. start() {
  21. }
  22. // 奖励图片数组
  23. protected onCreated(): void {
  24. super.onCreated()
  25. audioManager.playOneShot(BgmName.win)
  26. this.returnBtn.on(Node.EventType.TOUCH_END, this.return, this)
  27. this.againBtn.on(Node.EventType.TOUCH_END, this.again, this)
  28. audioManager.playOneShot(BgmName.fail)
  29. this.saiAnim()
  30. }
  31. return() {
  32. rootMgr.game.Change(FMSType.home)
  33. this.onClose()
  34. }
  35. again() {
  36. rootMgr.game.Change(FMSType.Start)
  37. this.onClose()
  38. }
  39. saiAnim() {
  40. rotate_anim_ext(this.light, 'loop', {
  41. duration: 3, // 每圈旋转时间(秒)
  42. angle: 360, // 每圈旋转角度(360度)
  43. });
  44. }
  45. onClose() {
  46. rotate_anim_stop(this.light); // 停止旋转动画
  47. super.onClose();
  48. }
  49. }