ResultUI.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { _decorator, Component, Node, sp } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('ResultUI')
  4. export class ResultUI extends Component {
  5. @property({type:Node,tooltip:'胜利界面'})
  6. win:Node = null;
  7. @property({type:Node,tooltip:'失败界面'})
  8. lose:Node = null;
  9. @property({type:sp.Skeleton,tooltip:'胜利动画'})
  10. winSpine:sp.Skeleton = null;
  11. @property({type:sp.Skeleton,tooltip:'失败动画'})
  12. loseSpine:sp.Skeleton = null;
  13. private _endcallback:Function
  14. protected onLoad(): void {
  15. this.loseSpine.setCompleteListener(this.actionComplete.bind(this))
  16. this.winSpine.setCompleteListener(this.actionComplete.bind(this))
  17. }
  18. show(bWin:boolean,callback:Function = null) {
  19. this.node.active = true
  20. if(bWin){
  21. this.win.active = true
  22. this.lose.active = false
  23. this.winSpine.setAnimation(0,'animation1',false)
  24. }else{
  25. this.win.active = false
  26. this.lose.active = true
  27. this.loseSpine.setAnimation(0,'animation1',false)
  28. }
  29. this._endcallback = callback
  30. }
  31. actionComplete(trackEntry:sp.spine.TrackEntry) {
  32. this.node.active = false
  33. this._endcallback&&this._endcallback()
  34. this._endcallback = null
  35. }
  36. }