Problem with CCFollow

Problem with CCFollow
0.0 0


Hi, i have modified the helloworld example by adding, in the method HelloWorld::init(), two sprites.
They are rendered perfectly (at the center of the screen). I apply a MoveTo() action to the first sprite (and it moves correctly):

// In the Helloworld::Init() method CCPoint position = pSprite1->getPosition(); position.x += 500; CCAction *action = CCMoveTo::actionWithDuration( 3, position ); pSprite1->runAction( action );

I want the second sprite to follow the first, so i add the following code:

// size is a CCSize object storing the width and height of the rendering window CCRect rect; rect.origin.x = 0; rect.origin.y = 0; rect.size.width = size.width; rect.size.height = size.height; CCFollow *action2 = CCFollow::actionWithTarget( pSprite1, rect ); pSprite2->runAction( action2 );

But the second sprite get displayed but doesn’t move at all. I have tried without setting the boundary in the actionWithTarget() method, but the sprite
get displayed only for 1 frame and then disappear.

Any idea about the possible causes of this strange behaviour? Maybe i have to add the action somewhere else?