1

我的游戏是用cocos2d-x设计的,图片资源大小为320x480,适配iphone4,现在我想让我的游戏适配iphone5,怎么办,谢谢!

4

2 回答 2

1

这实际上取决于您当前的 cocos2d-x 版本和您计划支持的分辨率。但基本上,如果您正在运行最新的稳定版本(2.0.4)并且只想支持 iPhone4 和 iphone5 分辨率,那么您必须:

  1. 为两种分辨率创建艺术(这不是强制性的,但图形可能会缩放太多并降低质量)。

  2. 在运行时根据实际设备的分辨率定义 DesignResolutionSize 和 ContentScaleFactor

  3. 选择正确的资源路径

这是一个关于如何实现它的简单示例:

// Get the real screen size
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);

// Set the design resolution. Please see the doc for the different modes
pEGLView->setDesignResolutionSize(480, 320, kResolutionNoBorder);

// Here you have to chose between width or height depending your game's design
if (frameSize.width > 480) {
      // iphone5
      pDirector->setContentScaleFactor(1136/480);
      CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");
} else { 
     // iphone4
     pDirector->setContentScaleFactor(1);
     CCFileUtils::sharedFileUtils()->setResourceDirectory("sd");
}

/// Now load the sprites....

如果您想支持更多的iOS/android分辨率,请参考以下链接了解cocos2d-x提供的全屏多分辨率解决方案:

http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Multi_resolution_support

http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Mechanism_of_loading_resources

希望它有所帮助。

于 2013-02-07T15:50:56.840 回答
0

Cocos2D-x 2.0.4+ 对多分辨率问题有非常简单的解决方案。(iDevices 或 Android 设备。)

事实上,您只需要设置您的DesignResolution,然后想象您的目标设备将具有此分辨率。

如果目标设备真的有这个分辨率(或其他一些但具有相同的比率)cocos2d 将处理修复屏幕,你的游戏在所有设备上看起来都一样。

当目标设备的比例不同时,你有很多选项(如 cocos2d 语言policy)来管理它。

例如,如果您使用Exact fit策略,cocos2d 将强制您的游戏(和设计)适合目标设备屏幕(没有那个黑色边框)。

完全适合

整个应用程序在指定区域中可见,而无需尝试保留原始纵横比。可能会发生变形,并且应用程序可能会出现拉伸或压缩。

有关更多详细信息,请查看此链接: http: //www.cocos2d-x.org/projects/cocos2d-x/wiki/Multi_resolution_support

于 2013-08-29T13:23:21.437 回答