I’m using cocos2d. After i load the ccspriteframecache and ccspritebatchnode, i made a ccsprite. But i need the contentsize of the sprite stage.
However it returns 480.000000, 320.000000 instead, which the size of the whole screen. My image is a lot smaller.
[[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFramesWithFile:@"nBack.plist"];
CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"nBack.png"]
CCSprite *stage = [CCSprite spriteWithSpriteFrameName:@"nBack0001.png"];
stage.position = ccp( winSize.width /2, winSize.height/2 );
CGSize stageSize = stage.contentSize;
NSLog( @"%f,%f", stageSize.width, stageSize.height );
[self addChild:stage z:1];
The contentSize is correct. You may want to double-check the dimensions of your image.
I can imagine that you drew the image on a 480×320 transparent background. That would leave the image size at 480×320 but the tools used to create the texture atlas will (temporarily) strip the extraneous transparent area. But it will still be used in the rendering of the image on the iPhone and affect your image’s contentSize.