这不起作用:
CCSprite *testscale=[CCSprite spriteWithSpriteFrame:starFrame];
testscale.scale=0.5;
float starWidth=testscale.contentSizeInPixels.width;
CCLOG(@"contentpixels: %f contentsize: %f",starWidth, testscale.contentSize.width);
Run Code Online (Sandbox Code Playgroud)
CCLOG中的两个输出都显示精灵的原始像素大小,而不是缩放后的大小.
有没有办法在没有这样做的情况下得到它?...
float displayWidth=starWidth*testscale.scale;
Ken*_*Toh 14
使用CCNode的boundingBox属性:
[testscale boundingBox].size.width
[testscale boundingBox].size.height
Run Code Online (Sandbox Code Playgroud)
这应该为您提供所需的宽度和高度,同时考虑到您对精灵所做的任何变换(缩放,旋转).