import { _decorator, Component, Node, sp } from 'cc'; const { ccclass, property } = _decorator; @ccclass('ResultUI') export class ResultUI extends Component { @property({type:Node,tooltip:'胜利界面'}) win:Node = null; @property({type:Node,tooltip:'失败界面'}) lose:Node = null; @property({type:Node,tooltip:'点击返回'}) back:Node = null; @property({type:sp.Skeleton,tooltip:'胜利动画'}) winSpine:sp.Skeleton = null; @property({type:sp.Skeleton,tooltip:'失败动画'}) loseSpine:sp.Skeleton = null; //是否等待动画播放完毕 bWait = false //是否动画播放完毕 bAnimOver = false private _endcallback:Function protected onLoad(): void { this.loseSpine.setCompleteListener(this.actionComplete.bind(this)) } show(bWin:boolean,bLast:boolean = false,callback:Function = null) { this.bAnimOver = false this.bWait = bLast this.back.active = bLast if(bWin){ this.win.active = true this.lose.active = false }else{ this.loseSpine.setAnimation(0,'lose',false) } this._endcallback = callback } actionComplete(trackEntry:sp.spine.TrackEntry) { this.bAnimOver = true if(this.bWait) return this.node.active = false this._endcallback&&this._endcallback() } onTouchButton() { this.bWait = false if(this.bAnimOver){ this.node.active = false this._endcallback&&this._endcallback() } } }