开发者

Getting the size of an image

I am currently changing textures with cocos2d using this

CCTexture2D* tex = [[CCTextureCache sharedTextureCache] addImage:
                        someImage.png];

[someSprite setTexture: tex];

But the issue is the image I send it to

[someSprite 开发者_C百科setTexture:tex withRect:someRect

How do I get the size of the image or get the rect size to set the CCSprite to with the texture.?

Thanks


try like this

 urSprite.contentSize


As said in http://www.cocos2d-iphone.org/api-ref/0.99.0/interface_c_c_texture2_d.html use tex.contentSize as a CGSize or make a CGRect by CGRectMake(0,0,tex.contentSize.width,tex.contentSize.height);


I think you were looking for tex.pixelsWide and tex.pixelsHigh. These are the dimensions of your texture in pixels.

Example:

[CCSprite spriteWithTexture:tex rect:CGRectMake(0, 0, tex.pixelsWide, tex.pixelsHigh)];

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜