如果你想保留上一个动画,请使用 HoldPrevious
。
TrackEntry entry = animationState.SetEmptyAnimation(0, 0.0f);
entry.HoldPrevious = true;
如果您确实需要使用“ClearTracks”,只需稍后调用回调即可:
public void YourCallbackMethod(TrackEntry entry) {
...
}
skeletonAnimation.AnimationState.Interrupt += YourCallbackMethod;
skeletonAnimation.AnimationState.End += YourCallbackMethod;
// 下面的ClearTrack不会发出事件,但你可以手动调用它。
TrackEntry currentEntry = skeletonAnimation.AnimationState.GetCurrent(trackIndex);
YourCallbackMethod(currentEntry);
skeletonAnimation.AnimationState.ClearTrack(trackIndex);
If you want to hold the previous animation, use HoldPrevious
.
TrackEntry entry = animationState.SetEmptyAnimation(0, 0.0f);
entry.HoldPrevious = true;
If you really need to use ClearTracks
, just call your callback afterwards:
public void YourCallbackMethod(TrackEntry entry) {
...
}
skeletonAnimation.AnimationState.Interrupt += YourCallbackMethod;
skeletonAnimation.AnimationState.End += YourCallbackMethod;
// ClearTrack below does not issue events, but you could manually call it.
TrackEntry currentEntry = skeletonAnimation.AnimationState.GetCurrent(trackIndex);
YourCallbackMethod(currentEntry);
skeletonAnimation.AnimationState.ClearTrack(trackIndex);