Question

I have two different sprites which i am binding together onto a third sprite with help of following link and code. But no CCAction runs on this new parent sprite. How can i join sprites into one and perform action on a single body??

tried CCFadeIn action on fatherSprite.. didn't work

combining-multiple-ccsprites

fatherSprite = [CCSprite node];
[fatherSprite setPosition:ccp(75,265)];

CCSprite *fatherBody = [CCSprite spriteWithFile:@"father-character.png"];
        [fatherBody setPosition:CGPointZero];
        [fatherSprite addChild:fatherBody];

CCSprite * fatherFace = [CCSprite spriteWithCGImage:image.CGImage key:nil];
        [fatherFace setPosition:ccp(83,80)];//277+image.size.height/4)];
        [fatherSprite addChild:fatherFace];

        [self addChild:fatherSprite];
Was it helpful?

Solution

if you want to animate child items, you need to apply animation to them not to the parent. so just loop through all childs and animate them

same way if you want to set parent opacity 0, you need to loop through childs and set alpha to zero

example:

for(CCSprite *sprite in container.children)
            [sprite runAction:[CCFadeIn actionWithDuration:0]];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top