Flicker while changing spine animation cocos2dx

500 views Asked by At

I am having an issue while using spine animation in cocos2dx. Here is the code

 skeletonNode = new CCSkeletonAnimation("Snake.json", "Snake.atlas");
   skeletonNode->setAnimation("Walk", true);
   skeletonNode->setScale(1.0);
   skeletonNode->setSlotsToSetupPose();
    CCSize windowSize = CCDirector::sharedDirector()->getWinSize();
    skeletonNode->setPosition(ccp(windowSize.width / 2, windowSize.height/2));
    addChild(skeletonNode);
    skeletonNode->release();

now when i change using add animation method, then for a second,it flickers while changing animation. I also tried clear animation before adding new animation but same problem.

this is how i change animation

skeletonNode->setSlotsToSetupPose();
skeletonNode->addAnimation("Sleep", true);    

i can not understand why it flickers. Please help me.

1

There are 1 answers

0
Davinder Singh On

When you add new animation to current frame it can't sync. with last frame.
so you should mix animation instead of add a new animation i.e.

skeletonAnimation->setMix("animation_1", "animation_2", duration);