COCOS2D for iOS - CCMoveTo does not work & hellip;

advertisements

sorry, my english level is very low.

my code...

CCNode *A = [self getChildByTag:kATag];
CCNode *B = [self getChildByTag:kBTag];

CCMoveTo *MoveAction = [CCMoveTo actionWithDuration:1.0f position:A.position.x, 0];

[A runAction:[[MoveAction]copy];
[B runAction:[[MoveAction]copy];

B sprite is moved. but A sprite does Not Move.

so, i added

[A stopAllActions];
[A runAction:[[MoveAction]copy];
[B runAction:[[MoveAction]copy];

but does not work.

[A setVisible:NO]

so, this code is work. Sprite A is Hide.

Why CCMoveTO does not work????


CCMoveTo was deprecated in V3, now CCActionMoveTo is used.

Try this:

CGPoint location = [touch locationInView:[touch view]];
CGPoint convertedLocation = [[CCDirector sharedDirector] convertToGL:location];

CCActionMoveTo *MoveAction = [CCActionMoveTo actionWithDuration:1.0f position:convertedLocation];

[A runAction:[[MoveAction]copy];
[B runAction:[[MoveAction]copy];