Content Size?


#1

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.


#2

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.


#3

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.


#4

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


#5

Masoud Soleimani wrote:

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

tried, not right…


#6

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