Reputation: 24750
This does not work:
CCSprite *testscale=[CCSprite spriteWithSpriteFrame:starFrame];
testscale.scale=0.5;
float starWidth=testscale.contentSizeInPixels.width;
CCLOG(@"contentpixels: %f contentsize: %f",starWidth, testscale.contentSize.width);
The two outputs in CCLOG both show the original pixel size of the sprite, not the size after scaling.
Is there a way to get it without doing this?...
float displayWidth=starWidth*testscale.scale;
Upvotes: 7
Views: 5777
Reputation: 3751
Use the boundingBox property of CCNode:
[testscale boundingBox].size.width
[testscale boundingBox].size.height
This should give you the width and height you want, taking into account any transformation (scaling, rotation) you have made to the sprite.
Upvotes: 14