Search code examples
c++cocos2d-x

Cocos2d-x: CCMoveTo not smooth after using many times


currently, I'm using touch end to move a sprite (also scale while moving)

void Sample::move(CCSprite* sprite){
    moveTo = CCMoveTo::create(0.5f,ccp(0, 3));
        scale = CCScaleTo::create(0.5f, 0.0f);
        sprite->runAction(CCSpawn::create(scale, moveTo, NULL));
}

after about 20 times call this function, the move action become not smooth.

Anyone can help me, why it become not smooth?


Solution

  • Weird things happen when you call actions and actions were already running (jumpy movements are common). Try calling stopAllActions() before runAction().