Yeah, that shouldn't be too hard 🙂
spAnimation
has a field called timelines
which is an array of spTimeline
instances. You can iterate over these and check for the timeline type SP_TIMELINE_EVENT
. Once you know that a timeline is an event timeline, you can cast that spTimeline
to spEventTimeline
(spine-runtimes/Animation.h at 3.6). The event timeline stores all the keys you set for that timeline in the Spine Editor. The frames
field stores the time of each frame, while the events
field stores a pointer to the event that will be triggered at that time.
Here's some (untested, pseudo-)code.
spTimeline** timelines = animation->timelines;
for (int i = 0; i < animation->timelinesCount; i++) {
spTimeline* timeline = timelines[i];
if (timeline->type == SP_TIMELINE_EVENT) {
spEventTimeline* eventTimeline = (spEventTimeline*)timeline;
for(int j = 0; j < eventTimeline->framesCount; j++) {
float frameTime = eventTimeline->frames[i];
spEvent* frameEvent = eventTimeline->events[i];
// do whatever you need to do here :)
}
}
}