quick3.3 spine骨骼动画帧事件不能注册问题

用到quick3.3中的spine(骨骼动画)
在动画某一帧添加event后,在通过
self.skeleteonNode:registerSpineEventHandler(handler(self, function(self,event)
dump(event)
if event.animation == “run” then
if event.name == “footstep” then
print(“footstep”)
end
end
end),sp.EventType.ANIMATION_EVENT)
这个方法得到事件为“footstep”,但是如果方法最后为sp.EventType.ANIMATION_EVENT或sp.EventType.ANIMATION_START或sp.EventType.ANIMATION_END,怎么也进入不到上面的function中,但是sp.EventType.ANIMATION_COMPLETE却可以,我通过断点找到了每一帧都会调用的方法,如下:

void spAnimationState_apply (spAnimationState* self, spSkeleton* skeleton) {
_spAnimationState* internal = SUB_CAST(_spAnimationState, self);

int i, ii;
int eventsCount;
int entryChanged;
float time;
spTrackEntry* previous;
for (i = 0; i < self->tracksCount; ++i) {
    spTrackEntry* current = self->tracks*;
    if (!current) continue;

    eventsCount = 0;

    time = current->time;
    if (!current->loop && time > current->endTime) time = current->endTime;

    previous = current->previous;
    if (!previous) {
        if (current->mix == 1) {
            spAnimation_apply(current->animation, skeleton, current->lastTime, time,
                current->loop, internal->events, &eventsCount);
        } else {
            spAnimation_mix(current->animation, skeleton, current->lastTime, time,
                current->loop, internal->events, &eventsCount, current->mix);
        }
    } else {
        float alpha = current->mixTime / current->mixDuration * current->mix;

        float previousTime = previous->time;
        if (!previous->loop && previousTime > previous->endTime) previousTime = previous->endTime;
        spAnimation_apply(previous->animation, skeleton, previousTime, previousTime, previous->loop, 0, 0);

        if (alpha >= 1) {
            alpha = 1;
            internal->disposeTrackEntry(current->previous);
            current->previous = 0;
        }
        spAnimation_mix(current->animation, skeleton, current->lastTime, time,
            current->loop, internal->events, &eventsCount, alpha);
    }

    entryChanged = 0;
    for (ii = 0; ii < eventsCount; ++ii) {
        spEvent* event = internal->events;
        if (current->listener) {
            current->listener(self, i, SP_ANIMATION_EVENT, event, 0);
            if (self->tracks* != current) {
                entryChanged = 1;
                break;
            }
        }
        if (self->listener) {
            self->listener(self, i, SP_ANIMATION_EVENT, event, 0);
            if (self->tracks* != current) {
                entryChanged = 1;
                break;
            }
        }
    }
    if (entryChanged) continue;

    /* Check if completed the animation or a loop iteration. */
    if (current->loop ? (FMOD(current->lastTime, current->endTime) > FMOD(time, current->endTime))
            : (current->lastTime < current->endTime && time >= current->endTime)) {
        int count = (int)(time / current->endTime);
        if (current->listener) {
            current->listener(self, i, SP_ANIMATION_COMPLETE, 0, count);
            if (self->tracks* != current) continue;
        }
        if (self->listener) {
            self->listener(self, i, SP_ANIMATION_COMPLETE, 0, count);
            if (self->tracks* != current) continue;
        }
    }

    current->lastTime = current->time;
}

}
这个方法中有个参数int eventsCount; 这个eventsCount被赋值为0,下面又有个循环for (ii = 0; ii < eventsCount; ++ii),但是这个局部变量的值并没有发生改变,所以怎么也执行不到for循环中的方法,也就找不到骨骼动画的帧事件了。本人新人一枚,看源码也是马马虎虎,希望有了解的前辈指教。如果是我的方法用错了,能直接告诉我正确的使用方法是最好了,谢谢大家了!*****

力求了解的大神指教,不胜感激:14:

擦嘞 木有人回答吗 今天问有人能用这个方法 为什么我不能用啊 资源问题会导致这个问题吗?

好吧 这个问题我已经自己解决了 原因是资源中没有events事件 让美工添加进去就好了 而eventCount这个值会发生变化是因为在下面的函数中用到了他的引用,在apply这个函数中(一步一步跟找到的)对这个值进行了改变,所以这个值会发生改变0.0
总结:奇怪的问题总是伴随着粗心而生成,希望大家引以为戒!

新人一枚 看到你的帖子 很大的帮助 非常感谢