Can FlipX CCSprite with it's children at once?


#1

Hi.

I wanna know how to flip CCSprite’s children at once.

Here’s my code.

CCSprite* head = CCSprite::spriteWithSpriteFrameName(“head.png”);
this~~>addChild;
head~~>setScale(0.5f);
>
CCSprite* eye = CCSprite::spriteWithSpriteFrameName(“eye.png”);
head~~>addChild;
>
head~~>setFlipX(true);

  • head.png is flip. but it’s child(eye.png) doens’t flip.

When I use method like setScale/setRotate on parent sprite, It’s children sprite also scale/rotate.
But setOpacity/setFlipX doesn’t apply it’s children. (contentSize also don’t contains it’s children size);

I want flip sprite with it’s children at once.
I should setFlipX each child manually?


#2

I found simple solution. :slight_smile:

Use minus scale value instead of setFlip. (parentSprite->setScaleX(–1.0f));
I work well.

But Still don’t know how to get contentSize contains all children’s area.


#3

Can I do this in a sequence… Coz I tried but always gets an error……

here is what i do

body~~>runAction),
body~~>setScaleX( -.5f),
CCMoveTo::create(2,ccp(2000,800)),
NULL) ) // Here I got the error…

) );