Scaled graphic and add children to sprite

Scaled graphic and add children to sprite
0.0 0


Hello there i have following problem:

I load 2 sprites
I set on them the same scale

and when i draw them separately everything is ok but when i want to do something like this:

CCSprite* sprite1;
CCSprite* sprite2;

The second sprite is drawn but it size is scaled? And boudingBox returns the same size when i don’t add them together and when 1 sprite add to another.

Sample you can see on screenshot

28 AM.png (276.5 KB)


Probably i found the bug when i scale when sprites are separately like this:
sprite2.setScale(sprite2.getScale() * sprite1.getScale())

i get the same result. (I think)

OK now scale is the same but still i have offset and boundingBox return wrong size ;/


OK i have found resolution but bug still exist

Before addChild i set here and here scale to 1
then i add
CCSprite* sprite1;
CCSprite* sprite2;
next set scale on sprite1

now images are drawn correct but bounding box is returned like it hasn;t any scale so you can simply * scale and all will be ok.

Simply do something like this:

rect2.origin.x = rect2.origin.x*R::SCALE + rect.origin.x;
rect2.origin.y = rect2.origin.y*R::SCALE + rect.origin.y;
LOG (" %i Wymiary super fali: w:%f h:%f",i,rect2.size.width,rect2.size.height);

Where rect1 is boundingBox from sprite1 and rect2 form sprite2

  1. Any changes you make on the parent will propagate through the child. For example, change the parent’s scale to 2.0, the child will also be scaled to 2.0.
  2. When using getContentSize() or boundingBox(), this will return the original sizes, not the scaled ones.
  3. The image you posted doesn’t quite help.

  1. True
  2. I can’t agree ;/

I can’t agree that boundingBox return orginal size because i use it a lot and boundingBox != contentSize

  1. Sorry i want only show what i mean only.

Thanks for the reply.


About point 1, is it possible to prevent propagation of parent properties to children? Scaling or rotation?