很遗憾听到您发现事件界面不直观。 Spine 保证发布您的事件,但根据您可能还不知道的规则。
很可能您在混用和 EventThreshold 方面遇到问题:
TrackEntry eventThreshold
事件阈值:浮动
当混合百分比 (mixTime / mixDuration
) 小于 eventThreshold 时,在混合此动画时应用事件时间线。默认为 0,因此在混合此动画时不会应用事件时间线。
或如此处所述:
Coding for Spine Events and AnimationState callbacks: User events during mixing
混合期间的用户事件
TrackEntry 的“EventThreshold”控制在混音期间如何处理用户事件。
- 使用默认值“0”,下一个动画开始播放时立即停止引发用户事件。
- 如果将其设置为“0.5”,则用户事件在交叉淡入淡出/混音的中途停止引发。
- 如果您将其设置为“1”,事件将继续上升,直到交叉淡入淡出/混合的最后一帧。
将 EventThreshold
设置为您的动画的适当值很重要,因为您可能有重叠的动画,它们具有相同的动画并且不应该引发相同的动画,或者希望即使动画被中断也仍然引发事件。
Sorry to hear that you find the event interface unintuitive. Spine guarantees that your events are issued, but according to rules which you may not know yet.
Most likely you are facing problems with mixing out and EventThreshold:
TrackEntry eventThreshold
eventThreshold: float
When the mix percentage (mixTime / mixDuration
) is less than the eventThreshold, event timelines are applied while this animation is being mixed out. Defaults to 0, so event timelines are not applied while this animation is being mixed out.
Or as described here:
Coding for Spine Events and AnimationState callbacks: User events during mixing
User events during mixing
A TrackEntry's EventThreshold
controls how user events are treated during the mix duration.
- With the default value
0
, user events stop being raised immediately when the next animation starts playing.
- If you set it to
0.5
, user events stop being raised halfway through the crossfade/mix.
- If you set it to
1
, events will continue to be raised up until the very last frame of the crossfade/mix.
Setting EventThreshold
to the appropriate value for your animations is important, as you may have overlapping animations that have the same animations and shouldn't raise the same ones, or want events to still be raised even if the animation has been interrupted.