开发者

In Retina mode of Cocos2D, how to autoscale PNG when -hd files are not present?

开发者 https://www.devze.com 2023-04-12 05:10 出处:网络
When I enable the retina mode, and when the -hd files are not present, the normal version of .png files are shown and therefore the image looks very small. How can I autoscale those PNG files tp 2x wh

When I enable the retina mode, and when the -hd files are not present, the normal version of .png files are shown and therefore the image looks very small. How can I autoscale those PNG files tp 2x when the -hd开发者_如何学编程 files are not present?


Short answer: you don't.

If you're supporting Retina, you should support it all the way by providing all images in SD and HD variants. If needed, you can scale up (2x) an SD image with an image editing program. If that program uses filters (ie bicubic filtering) the upscaled image won't look as bad if you upscaled it on the fly using the scale property of sprites.

If you don't have any HD images, turn off Retina support. There's no point in supporting Retina displays if you can't provide all or most images in HD resolution.


You should use the following code to adjust the content scale factor:

[[CCDirector sharedDirector] setContentScaleFactor: 1.0];

and in CCDirectorIOS use:

-(void) setViewport {
     CGSize size = _winSizeInPixels;
     glViewport(0, 0, size.width * screenScale, size.height * screenScale);
}

It's work for me!

0

精彩评论

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

关注公众号