CCSequence Firing Actions in Cocos2d

I have three actions that run in CCSequence . I so want to shoot that the first sprite should move in the center of the screen, and then the scale of the action is fired. But for some reason, the sprite moves to the center of the screen correctly, but when the scale starts, it uses the old position of the sprite.

 id actionRotate = [CCRotateBy actionWithDuration:0.6 angle:360]; id disappear = [CCFadeTo actionWithDuration:.5 opacity:0]; id actionMoveDone = [CCCallFuncN actionWithTarget:self selector:@selector(removeAlphabetToFindFromView:)]; id actionScale = [CCScaleBy actionWithDuration:0.6 scaleX:10 scaleY:10]; id moveTo = [CCMoveTo actionWithDuration:0.6 position:ccp(windowSize.width/2, windowSize.height/2)]; //[self removeAlphabetToFindFromView2:alphabetToFind]; [alphabetToFind runAction:[CCSequence actions:moveTo,actionScale,disappear,actionMoveDone, nil]]; 

UPDATE 1:

Perhaps the startAnimation method has something to do with this. I have the public variables x and y that are used as x and y positions for 4 different sprites:

 -(void) startAnimation:(CCSprite *) sprite { [self generateRandomCoordinates]; id actionMove = [CCMoveTo actionWithDuration:3.0 position:ccp(x,y)]; id actionRotate = [CCRotateBy actionWithDuration:0.0 angle:rotateBy]; id actionMoveDone = [CCCallFuncN actionWithTarget:self selector:@selector(finishedMoving:)]; [sprite runAction:[CCSequence actions:actionMove,actionRotate, actionMoveDone, nil]]; } -(void) finishedMoving:(id) sender { if(counter == randomAlphabets.count) { counter = 0; } CCSprite *sprite = [randomAlphabets objectAtIndex:counter]; [self generateRandomCoordinates]; [self startAnimation:sprite]; counter +=1; } 

UPDATE 2:

As expected, the x and y used in the startAnimation ( getRandomCoordinates ) method are causing the problem. So, I deleted all the actions before starting the sequence, and now it works fine.

+4
source share

All Articles