Gur*_*uru 5 cocos2d-iphone ios iphone-5
我用过Cocos2d:
-hd.png for iPhone HD
-ipad.png for iPad.
-ipadhd.png for iPad HD.
Run Code Online (Sandbox Code Playgroud)
像这样我们需要为iPhone 5使用哪个扩展?另外如何在cocos2d中启用iPhone 5支持?
更新1:我们很容易就像这样支持iPhone5
#define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568)?NO:YES)
#define TEX_GAME_BG (IS_IPHONE5) ? ( @"bg-whd.png") : ( @"bg.png")
mBG1 = [CCSprite spriteWithFile:TEX_GAME_BG];
Run Code Online (Sandbox Code Playgroud)
更新2: 使用通用功能...将其放在cocos2d.h或任何常见文件中
static inline NSString *i5res(NSString * data)
{
if(IS_IPHONE5)
{
return [data stringByReplacingOccurrencesOfString:@"." withString:@"-whd."];
}
return data;
}
//usage
CCSprite *bg = [CCSprite spriteWithFile:i5res(@"bg.png")];
Run Code Online (Sandbox Code Playgroud)
更新3: Cocos2d现在也支持iphone5.-iphone5hd
imageName-iphone5hd.png for iPhone 5 HD.
Run Code Online (Sandbox Code Playgroud)
cocos2d 中没有针对 iPhone5 尺寸图像的扩展。如果您需要使用这样的图像,则必须自己加载它们。
也许还想一下如何才能完全避免这些图像。如果您使用背景图像,也许您可以使用平铺图像代替?
要启用 iPhone 5 支持,与任何 iOS 项目相同,只需将 Default-568h@2x.png 启动图像添加到您的项目中即可。
| 归档时间: |
|
| 查看次数: |
2189 次 |
| 最近记录: |