Forum > C++ > Sprite scale to wrong size when you add it on another sprite ?

Sprite scale to wrong size when you add it on another sprite ?

By zhihmeng Posted 2012-02-14 04:00 Comments 2
zhihmeng
  • Posts: 110

Before I run deep into code logic, I want to ask if someone has this problem too.

I have a layer and 3 sprites: s1, s2 and s3.

If I add s1, s2 and s3 as layer’s child, and the scale is perfect, without any problems.

But if I add s1 as layer’s child, s2 as s1’s child and s3 as s2’s child.

It will be wrong scale size on iPhone, but seems fine on iPhone Retina.

I still don’t know why right now, but I may try to trace the code to find what happened later.

BTW, these three sprites will be scaled to 0.5 on iPhone(480x320), because I share the textures between iPhone Retina and iPhone.

Thank you.

zhihmeng
  • Posts: 110

#1 RE: 2012-02-14 04:44

sorry…guys…

I found the problem myself.

There is one thing that I didn’t aware before.

If you add a CCNode as another’s child, and this CCNode will be inherited some properties of it’s parent’s.

Scale is the property it will be inherited.

So, I scale the s1 to 0.5 on iPhone and it’s child - s2 will also become 0.5 on scale size.

That’s why I get wrong sprite size on iPhone(480x320).

rophiroth
  • Posts: 12

#2 RE: 2012-05-23 16:03

You are right, that happen to me too, but still kind of buggy, child must have the ability to override parent properties.

Loggin to reply

Copyright © 2010 - 2013 Cocos2d-x.orgClustrmaps