2012-01-31 10 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 में दो outputs दोनों स्केलिंग के बाद आकार स्प्राइट के मूल पिक्सेल आकार, नहीं दिखा।

वहाँ एक रास्ता ऐसा किए बिना यह प्राप्त करने के लिए है ...

float displayWidth=starWidth*testscale.scale;

उत्तर

14

उपयोग CCNode की boundingBox संपत्ति:

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

यह आपको चौड़ाई देना चाहिए और जिस ऊंचाई को आप चाहते हैं, उसमें किसी भी परिवर्तन (स्केलिंग, रोटेशन) को ध्यान में रखते हुए आपने स्प्राइट को बनाया है।

संबंधित मुद्दे