ios - 如何实现构建一个通用的cococs2d应用程序?

标签 ios iphone xcode ipad cocos2d-iphone

我正在为 iphone 和 ipad 构建一个 iphone 应用程序。我有包含我的图像的纹理打包器 .plists。我有一个普通版,一个-hd版,一个ipad版,一个ipadhd版。

例如,如果我目前正在构建我的菜单,我是否通过执行以下操作来设置所有菜单?

[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"x_buttons.plist"];
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"x_buttons-hd.plist"];
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"s_buttons-ipad.plist"];
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"s_buttons-ipadhd.plist"];

当我创建一个按钮时,xcode 如何根据设备“知道”使用哪个 plist? (iphone5、iphone4、视网膜、ipad 等)

感谢您帮助制作通用应用程序

最佳答案

约翰

只需要写[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"x_buttons.plist"];

AppDelegate.mdidFinishLaunchingWithOptions方法中,
更改以下行。

CCFileUtils *sharedFileUtils = [CCFileUtils sharedFileUtils];  
[sharedFileUtils setEnableFallbackSuffixes:NO];             // Default: NO. No fallback suffixes are going to be used
[sharedFileUtils setiPhoneRetinaDisplaySuffix:@"-hd"];      // Default on iPhone RetinaDisplay is "-hd"
[sharedFileUtils setiPadSuffix:@"-ipad"];                   // Default on iPad is "ipad"
[sharedFileUtils setiPadRetinaDisplaySuffix:@"-ipadhd"];    // Default on iPad RetinaDisplay is "-ipadhd"` 

这将帮助 Xcode 通过 iPad、iPad Retina 或 iPhone Retina 建筑的后缀找到您的资源文件。

查看本教程,
http://www.raywenderlich.com/32049/texture-packer-tutorial-how-to-create-and-optimize-sprite-sheets-in-cocos2d .

关于ios - 如何实现构建一个通用的cococs2d应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21156064/

相关文章:

php - ImageMagick 没有此图像格式的解码委托(delegate)

iphone - ASIFormDataRequest POST 错误 - iOS 6

ios - 如何将我的应用程序作为模块包含在 Swift Playground 中?

ios - 使用 Interface Builder 为 UITabBarViewController 设置委托(delegate)时应用程序崩溃

ios - UIAlertView 改变 UITabbar item 选中的颜色

objective-c - 何时重写 objective c getters

ios - swift ||从 Superview 动画和删除 subview 时的错误

iPhone 开发 - 如何在不使用浏览器的情况下在应用程序中显示谷歌地图?以及其他 map 问题

iphone - UITableViewCell 子类不工作

ios - ionic3 - 无效的 App Store 图标。 'YourApp.app' Assets 目录中的 App Store Icon 不能透明,也不能包含 alpha channel