2012-01-31 68 views
7

這不起作用後如何獲得CCSprite的大小:改變規模

CCSprite *testscale=[CCSprite spriteWithSpriteFrame:starFrame]; 
     testscale.scale=0.5; 
float starWidth=testscale.contentSizeInPixels.width; 
     CCLOG(@"contentpixels: %f contentsize: %f",starWidth, testscale.contentSize.width); 

在CCLOG兩個輸出都表現出精靈的原始像素大小,不結垢後的尺寸。

有沒有辦法得到它沒有這樣做......

float displayWidth=starWidth*testscale.scale;

回答

14

使用CCNode的boundingBox的屬性:

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

這應該給你的寬度和考慮到你對精靈所做的任何轉換(縮放,旋轉)。