快速連結

2021年12月7日

[筆記]複數個Spine物件不同時間出現,動畫要一致

規格需求:
  • 第二個Spine物件,動畫要跟第一個出現的Spine物件,動畫要一致
  • Spine動畫修改animationStart時間時,會有一個先從頭開始播再直接跳到指定時間的Bug。故使用addAnimation + delay時間來控一下這個狀況。
  • Spine動畫修改animationStart時間後,每次loop都會從指定的Start time開始播放,因此第一次不要Loop,等播完一次後再打開Loop。

public PlayLoopAnim(startTime: number){
    if (this.isBingoTime)
       return;
    if (startTime > 0){
       let entry: sp.spine.TrackEntry = this.spine.addAnimation(0, "Loop", false, 0.1);
       entry.animationStart = startTime + 0.1;    //Delay時間
       this.spine.setCompleteListener(this.OnPlayLoopOnceEnd.bind(this));
    }else{            
       this.spine.addAnimation(0, "Loop", true);
    }
}

private OnPlayLoopOnceEnd(){
   this.spine.setCompleteListener(null);
   let entry: sp.spine.TrackEntry = this.spine.addAnimation(0, "Loop", true);
   entry.animationStart = 0;
}

沒有留言:

張貼留言

歡迎大家留言提問,我會答的都會盡力回答!
如果太久沒出現回應就是我又忘記回來看留言了TAT