That's the question xD
Given an instance of a CCSprite in cocos2d in iphone, what method can I use to obtain the image width and height?
Thanks! Manuel
That's the question xD
Given an instance of a CCSprite in cocos2d in iphone, what method can I use to obtain the image width and height?
Thanks! Manuel
The CCSprite class has a bounding box property that's a CGRect:
CCSprite *sprite = [CCSprite spriteWithFile: @"file.png"];
int width = [sprite boundingBox].size.width;
I added a width and height methods to my CCSprite subclass.
-(CGFloat) width
{
return [self boundingBox].size.width;
}
-(CGFloat) height
{
return [self boundingBox].size.height;
}
raw width:
sprite.contentsize.width
raw height:
sprite.contentSize.height
current widht:
sprite.conentsize.widht * sprite.scaleX
current height:
sprite.conentsize.height * sprite.scaleY