What is the difference between getContentSize() and getBoundingBox() with regards to a sprite

I have noticed that the result of
1- sprite->getContentSize()
and
2- sprite->getBoundingBox().size()
are different when scaling is involved usually the content size is smaller in value than the bounding box. I would appreciate it if someone could explain to me what the difference is between the two.

Here is what I observed. In case i do not scale my sprite I get the same results from sprite->getContentSize() and sprite->getBoundingBox().size() . However if I scale my sprite in the following way

 s->setScaleX((screenSize.width / s->getContentSize().width) * 1); //where screenSize is the Visible size

then the bounding box size is greater than the content size. Why is that ?

1 Like

The bounding box is essentially ContentSize * scale. It’s conceptually the actual box that contains the sprite/node. For non-texture objects it’s kinda virtual, but it’s still just whatever size you set * scale.

It gets more tricky to figure out positions and screen sizes of nodes if say node A is a child of a node B which is a child of node C and all three nodes have scales != 1.0f. If you want to learn how this works mathematically start reading the source of BoundingBox and CCNode.cpp along with searching for “Affine Transforms”.