import { CCString, Color, Component, sp, _decorator} from 'cc'; const { ccclass, property } = _decorator; /** * spine动画表现管理 * @author */ @ccclass('UISpineMovie') export default class UISpineMovie extends Component { @property({ type: [CCString], displayName: '动画列表' }) private animat_names: Array = []; @property({type: sp.Skeleton, tooltip: '角色动画' }) private spine:sp.Skeleton = null!; private cur:string =null!; private index:number=0; onLoad() { } start(){ //this.spine.clearTracks() /*this.spine.setStartListener(function(){ console.log("动画开始") }.bind(this));*/ /* this.spine.setEventListener(((trackEntry:any, event:any) => { //var animationName = trackEntry.animation ? trackEntry.animation.name : ""; //console.log("[track %s][animation %s] event: %s, %s, %s, %s", trackEntry.trackIndex, animationName, event.data.name, event.intValue, event.floatValue, event.stringValue); this.unit.DoEvent(event.data.name); }) as any);*/ // //let duration = this.spine.getCurrent(0).animation.duration; //let frames = Math.ceil(frameRate * duration); //let secondsPerFrame = 1 / frameRate; //`总帧数 ${this.frames}`; //this.spine.setCompleteListener(trackEntry => { //}); if(this.animat_names.length>0){ this.index=0; if(this.index==this.animat_names.length-1){ this.DoAnimation(this.animat_names[this.index],true); }else{ this.DoAnimation(this.animat_names[this.index],false); } this.spine.setCompleteListener(function(){ this.index++; if(this.index{ this.spine.color = reColor; },time); } } /** * 缩放动画播放速率 * @override * @param scale 缩放倍率 */ public scaleTime(scale: number) { if (scale > 0) this.spine.timeScale = scale; } public getBone(name: string): any { var bone = this.spine.findBone(name); return bone } }