Hi everyone,
I’m developing a game that using Spine animation. My problem is I don’t know how to preload SkeletonAnimation properly.
I tried this but the game still takes a short moment for first time spine animation played.
spAtlas* atlas = spAtlas_createFromFile("skill_poison.atlas", 0);
CCASSERT(atlas, "Error reading atlas file.");
spSkeletonJson* json = spSkeletonJson_create(atlas);
SkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(json, "skill_poison.json");
CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data file.");
spSkeletonJson_dispose(json);
SkeletonAnimation* animation = SkeletonAnimation::createWithData(skeletonData);
I appreciate your helps. Thanks.
Have you tried creating the SkeletonAnimation directly from the files?
SkeletonAnimation* animation = SkeletonAnimation::createWithFile("skill_poison.json", "skill_poison.atlas");
I’m just now starting to experiment with Spine animations and this is how I’ve been loading them.
Hi toojuice,
Thank you for your idea. I tried your idea before but there’s a glitch when SkeletonAnimation first time played.
I think preloading animation will solve this problem but I don’t know how to do it properly.
What kind of glitch are you seeing? (A short pause before the animation starts?)
Where are you creating your SkeletonAnimation?
Hi toojuice,
Yes, there’s a short pause before the animation first time started. But when I create and start the animation second time and so on, there’re no glitch.
I create and start SkeletonAnimation when user use skills by clicking on button “SKILL”. Every time user use skills, they have to wait 5 seconds to use skills again.