fail.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { _decorator, Component, Node } from 'cc';
  2. import { gameManager } from '../gameManager';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('fail')
  5. export class fail extends Component {
  6. @property(Node) btn_close:Node = null;
  7. @property(Node) btn_fail_reLife:Node = null;
  8. @property(Node) btn_fail_reStart:Node = null;
  9. private m_call_relife = null;
  10. private m_call_restart = null;
  11. public show(is_relife:boolean,call_relife,call_restart){
  12. this.node.active = true;
  13. this.m_call_relife = call_relife;
  14. this.m_call_restart = call_restart;
  15. if(is_relife){
  16. this.btn_fail_reLife.active = true;
  17. }else{
  18. this.btn_fail_reLife.active = false;
  19. }
  20. this.btn_fail_reLife.off(Node.EventType.TOUCH_END)
  21. this.btn_fail_reStart.off(Node.EventType.TOUCH_END)
  22. this.btn_close.off(Node.EventType.TOUCH_END)
  23. this.btn_fail_reLife.on(Node.EventType.TOUCH_END,()=>{
  24. if(this.m_call_relife!=null){
  25. this.m_call_relife()
  26. }
  27. })
  28. this.btn_fail_reStart.on(Node.EventType.TOUCH_END,()=>{
  29. if(this.m_call_restart!=null){
  30. this.m_call_restart()
  31. }
  32. })
  33. this.btn_close.on(Node.EventType.TOUCH_END,()=>{
  34. this.node.active = false;
  35. if(gameManager.Singleton.getLevelData()!=null){
  36. gameManager.Singleton.backGameList()
  37. }
  38. })
  39. gameManager.Singleton.sys_fail_prompt_music()
  40. }
  41. }