PaolaJ.
PaolaJ.

Reputation: 11532

Add sprite after scale also get scaled

I have to Sprites A and B ( A is human body and B is head ). I want to add sprite B to sprite A and to move together and I done this by A->addChild(B) and it works. Problem is when I want to scale only body and then add head to small body ( head should be normal size ) and I done this like

A->setScaleY(0.3);
A->addChild(B);

but I also get B to be scaled. How to scale only body and then add head of normal size to small body ?

Upvotes: 0

Views: 243

Answers (2)

justbilt
justbilt

Reputation: 478

Two way to solution this.

  1. Node/Sprite C

    Sprite A;
    Sprite B;
    Sprite C;
    
    A->setScaleY(0.3);
    
    C->addChild(A);
    C->addChild(B);
    
  2. also set B scale.

    float scale = 0.3f;
    A->setScaleY(scale);
    B->setScaleY(1/scale);
    A->addChild(B);
    

Upvotes: 1

Elensar
Elensar

Reputation: 124

B is child of A so will be scaled with A this is correct... I recommend you to make third Sprite C (skeleton) and add A(body), B(head) sprites to it. After that you can scale A, B independent and move them all with sprite C or scale whole human body with all your parts with C(skeleton) sprite.

Upvotes: 1

Related Questions