简体   繁体   English

Cocos2d中的视网膜和非视网膜图形

[英]Retina and Non Retina Graphics in Cocos2d

I have a game in iphone already developed one year back in older version of cocos2d. 我有一部iPhone的游戏已经在一年前使用较旧版本的cocos2d开发。

Now i want to upgrade the game with both retina and non-retina graphics for all iphone3G,3GS and 4+ devices. 现在我想为所有iphone3G,3GS和4+设备同时使用视网膜和非视网膜图形升级游戏。

I have used many buttons and CCMenus how can i handle them in code. 我已经使用了许多按钮和CCMenus,如何在代码中处理它们。 Do i have to write conditions for every graphic? 我必须为每个图形写条件吗?

Any help or tutorial? 有帮助或教程吗?

Thanks in advance 提前致谢

No, you dont need to do the conditional coding.... You can have the retina display support bye either un-commenting or adding the below code into your appDelegate.m/.mm file in the applicationDidFinishLaunching 不,您不需要进行条件编码。...您可以通过取消注释或在applicationDidFinishLaunching的appDelegate.m / .mm文件中添加以下代码来支持视网膜显示。

    if( ! [director enableRetinaDisplay:YES] )
    CCLOG(@"Retina Display Not supported");

Also you need to add "-hd" suffix image files for the retina display of the iPhone. 另外,您还需要为iPhone的视网膜显示添加“ -hd”后缀图像文件。

For cocos2d version 2 you need the "-ipad" & "-ipadhd" files to be present in your Resources folder. 对于cocos2d版本2,您需要在“资​​源”文件夹中显示“ -ipad”和“ -ipadhd”文件。

To upgrade the cocos2d version you can follow the steps on this Link . 要升级cocos2d版本,您可以按照此链接上的步骤进行操作。 But cocos2d version 2 supports 3GS and above iPhone. 但是cocos2d版本2支持3GS及更高版本的iPhone。

Hope this information would help you. 希望这些信息对您有所帮助。

As I know, the iOS will do this for you if you name the image file in a correctly way. 据我所知,如果您以正确的方式命名图像文件,iOS将为您执行此操作。 ex: normal screen: banner.png Retina screen: banner@2x.png 例如:正常屏幕:banner.png视网膜屏幕:banner@2x.png

The only thing you need to do is name the higher resolution image by a same name with the lower one and add subfix "@2x" 唯一需要做的就是用与较低的图像相同的名称命名高分辨率的图像,然后添加子前缀“ @ 2x”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM