您好!我正在运行使用Cocos2d的最基本的Hello World应用程序,从Xcode中最基本的cocos2d模板中完全不修改。
当我启动模拟器时,iPhone 5的启动图像会自动加载 - 但是几秒钟之后,启动图像会切换到iPhone 4的默认@ 2x,因此在两侧的两个未使用空间的小背条纹发射图像。
为什么会这样?我怎样才能使启动图像在几秒钟后不会自动切换到iPhone 4的较小版本?
由于
答案 0 :(得分:0)
在IntroLayer.mm中添加以下代码:
CCSprite *background;
if( IS_IPAD)
{
if(IS_RETINA)
background = [CCSprite spriteWithFile:@"Default-Portrait@2x~ipad.png"];
else
background = [CCSprite spriteWithFile:@"Default-Portrait~ipad.png"];
}
else
{
if(IS_IPHONE5)
background = [CCSprite spriteWithFile:@"Default-568h@2x.png"];
else
{
if(IS_RETINA)
background = [CCSprite spriteWithFile:@"Default@2x.png"];
else
background = [CCSprite spriteWithFile:@"Default.png"];
}
}
使用过的宏:
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE5 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0f)
#define IS_RETINA ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] && ([UIScreen mainScreen].scale == 2.0))