Content Size?

After you scale and image, getContentSize still returns the size of the image before it was scaled. What is the best way to get the current size of an image, even if it has been scaled?

Thanks.

use getContentSizeInPixels instead.
getContentSize will always return the width & height in point.
Plz reference to Riq’s document RetinaDisplay in cocos2d
Hope my answer can help you.

Thanks for the response.

I guess I was looking for something more like this:

sprite~~>getContentSize.width * sprite~~>getScaleX() this way I would get the actual width based off the scaling and the original size. I just thought maybe Cocos2d had a way of returning this without me actual calculating it out.

thanks again.

Try Using sprite->boundingBox().size.width always returns the scaled size of a sprite

1 Like

Masoud Soleimani wrote:

Try Using sprite->boundingBox().size.width always returns the scaled size of a sprite

tried, not right…

Ok i have the same problem.

getContentSizeInPixels also returns wrong width.

I use boundingBox() from CCNode and it works. I get scaled width of my CCSprite