FailPanel.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * 代码描述
  3. */
  4. import { Audio } from "../../common/src/Audio";
  5. import { UIManager } from "../../common/src/UIManager";
  6. import { Utils } from "../../common/src/Utils";
  7. const { ccclass, property } = cc._decorator;
  8. @ccclass
  9. export class FailPanel extends cc.Component {
  10. @property({ type: cc.Node, tooltip: '按钮节点' })
  11. button: cc.Node = null;
  12. @property({ type: cc.AudioClip, tooltip: '音效节点' })
  13. click: cc.AudioClip = null;
  14. onEnable() {
  15. this.button.getChildByName('restart').on('click', this.onRestart, this);
  16. this.button.getChildByName('resurgence').on('click', this.onResurgence, this);
  17. Utils.openPanel(this.node.getChildByName('panel'));
  18. Utils.btnTween(this.button.getChildByName('resurgence'));
  19. Audio.playSoundByPath('fail:res/snd/fail');
  20. }
  21. /**再来一次 */
  22. private onRestart(): void {
  23. Audio.playSoundByPath('fail:res/snd/click');
  24. UIManager.close('fail:FailPanel', true);
  25. cc.systemEvent.emit('restart');
  26. }
  27. /**复活 */
  28. private onResurgence(): void {
  29. Audio.playSoundByPath('fail:res/snd/click');
  30. UIManager.close('fail:FailPanel', true);
  31. cc.systemEvent.emit('updateBubble', 5);
  32. }
  33. }