ButterBeast
ButterBeast

Reputation: 551

CCTexture2D created texture.size not equal that image.size (only on iPad --> iPad simulator works fine)

I have very weird problem. When I run this code

CCTexture2DMutable * texture = [[CCTexture2DMutable alloc] initWithCGImage:image.CGImage resolutionType: kCCResolutioniPadRetinaDisplay];

    CGFloat heightOfImage = image.size.height;
    CGFloat heightOfTexture = texture.contentSize.height;

initWithCGImage is mathod that was inherit from CCTexture2D. image <-- UIImage

I get very weird result:

On iPad simululator (works fine):

heightOfImage = 1024

heightOfTexture = 1024

On iPad (retina) (not equal???):

heightOfImage = 1024

heightOfTexture = 512

Does any one know why? It drives me crazy.

If I change kCCResolutioniPadRetinaDisplay to kCCResolutioniPad the problem is the same.

Upvotes: 1

Views: 359

Answers (1)

Stephane Delcroix
Stephane Delcroix

Reputation: 16232

Cocos use points for measurement, not pixels (anymore). That's why the image size (in pixels) is different from the texture size (in points)

Upvotes: 1

Related Questions