How to get CCSprite size after zooming

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 show the original sprite pixel size, not the size after scaling.

Is there any way to get this without doing this? ...

float displayWidth=starWidth*testscale.scale;

+7
source share
1 answer

Use the boundingBox property for CCNode:

 [testscale boundingBox].size.width [testscale boundingBox].size.height 

This should give you the necessary width and height, taking into account any transformation (scaling, rotation) that you did for the sprite.

+14
source

All Articles