AnimationState中注册了Start 和End的回调事件,我在切换动画时,先调用的是新动画的start,然后再调用老动画的End,比如说我先播放了动画delfault1,然后播放动画default2,现在的回调顺序是

  1. delfault1 start
  2. delfault2 start
  3. delfault1 end

如何能改成

  1. delfault1 start
  2. delfault1 end
  3. delfault2 start
Related Discussions
...

如果两个动画之间有混合过渡,则“default2”将在“default1”结束之前启动。

为什么要将正确的回调顺序更改为不正确的顺序? 可能您的预期游戏逻辑应该对事件做出不同的反应。



If you have a mix transition between the two animations, default2 will be started before default1 ends.

Why would you want to change the correct sequence of callbacks to an incorrect one? Likely your intended gameplay logic should react to events differently.

请注意,您可能不想听“End”,而是想听“Interrupt”。 请参阅此处的文档:
http://esotericsoftware.com/spine-api-reference#AnimationStateListener-interrupt


Note that instead of listending to End, you might instead want to listen to Interrupt. See the documentation here:
http://esotericsoftware.com/spine-api-reference#AnimationStateListener-interrupt

    嗯,确实 listending Interrupt ,解决了我的问题!我还有一个问题,我播放了一个动画 default1
    有2个需求:
    1.我在播放一半的时候要停止这个动画且回到这个动画的第一帧,且调用到Interrupt事件
    2.我在播放一半的时候直接停止到当前帧,且都要调用到Interrupt事件

    Harald 给看个新问题

    恐怕机器翻译无法正确翻译您的消息。 翻译过来是你想重置到第一帧并“调用中断事件”。

    您想知道如何将播放时间更改为第一帧吗? 请参阅 TrackEntry.TrackTime。 或者,如果您希望发生混合过渡,您可以通过“AnimationState.SetAnimation()”设置相同的动画。

    关于“调用中断事件”:您能解释一下您想对中断事件做什么吗? 如果你问如何调用该事件,那么答案是你自己不调用它。 当然,您可以随时调用连接到事件的方法,因为它是您自己的用户代码。



    I'm afraid machine translation failed to translate your message properly. The translation reads that you want to reset to the first frame and "call the interrupt event".

    Do you want to know how you can change the playback time to the first frame? See TrackEntry.TrackTime. Alternatively you could set the same animation via AnimationState.SetAnimation() if you want a mix transition to happen.

    Regarding "call the interrupt event": Could you explain what you want to do in regards to the interrupt event? If you ask how you can call the event, then the answer is that you don't call it yourself. Of course you can call the method that you hooked up to the event at any time, since it's your own user code.

    当我播放了一个spine动画 名字为 “default”, 有时候遇到一个情况需要停止动画在我想停止的那一时刻,且停止后我需要通知到 有监听Interrupt事件的回调函数

    When I play a spine animation named "default", sometimes I encounter a situation where I need to stop the animation at the moment I want to stop, and after I stop, I need to be notified that there is a callback function that listens to the Interrupt event

    "I initiated playback of a Spine animation named 'default.' On certain occasions, a scenario arises where it becomes necessary to halt the animation precisely at the desired moment. Subsequent to the cessation, it is imperative to convey a notification to callback functions subscribed to the 'Interrupt' event listener." a professional translation

    我不确定我是否明白问题所在。 如果你通过添加空动画来停止动画,你将得到正常的回调,如“Interrupt”、“End”等。如果你不停止动画并执行其他操作,例如 设置不发出事件的“TimeScale”,您可以简单地手动调用事件回调函数。 或者有什么因素导致后者出现问题?

    如果以上都不是您想要做的,您能否在代码中描述您当前正在做什么以及当前不起作用?



    I'm not sure I understand what the problem is. If you stop the animation by adding the empty animation, you will get the normal callbacks like Interrupt, End, etc. If you don't stop the animation and do something else, e.g. setting TimeScale which does not issue events, you can simply call your event callback function manually. Or is there anything causing problems with the latter?

    If none of the above is what you want to do, could you please describe in code what you are currently doing, and what currently does not work?

    SetEmptyAnimation 的确能调用到 Interrupt, End,但是我还想使用clearTracks这个功能, 使skeleton保持当前姿势,且还能调用到Interrupt, End

    如果你想保留上一个动画,请使用 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);