你能相信我们还在使用Cocos2d-iPhone吗?
有人有办法让它与最新的iPad和iPhone X一起工作吗?
我们的模式是景观。
发布于 2018-10-09 16:59:38
1. Use buttons and other image from iPhone5HD and manually load background for iPhone XCCSprite *bg;if(App isIphoneX) { bg = CCSprite spriteWithFile:@“背景-iphoneX.png”;// 1624X750映像大小}-{ bg = CCSprite spriteWithFile:@"Background.png";//确保-hd、-ipad、-ipadhd、-iphone5hd存在}
或者只是缩放bg图像
#define SW ([[CCDirector sharedDirector] winSize].width)
#define SH ([[CCDirector sharedDirector] winSize].height)
CCSprite *bg ;
if([App isIphoneX])
{
bg = [CCSprite spriteWithFile:@"Background.png"];
bg.scaleX = SW/bg.contentSize.width;
bg.scaleY = SH/bg.contentSize.height;
} 应用程序代表代码:
-(bool)isIphoneX
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
if (screenSize.width == 812) // portrait height = 812
{
return true;
}
if([self isIphoneXR]) // Now in this game iPhoneXR, iPhoneXS Max = iPhoneX,
{
return true;
}
}
return false;
}
-(bool)isIphoneXR
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
if (screenSize.width == 896 && screenSize.height == 414)
{
return true;
}
}
return false;
}注意:我刚刚支持iPhoneX,我的旧game...Apple的所有设备支持最近都批准了这个change...successfully添加了对cocos2d 2.2的iPhoneX支持
发布于 2020-11-08 01:16:15
古鲁的解决方案是不完整的。他的解决方案以2 (1624x750)的比例尺加载iPhone X图像,而不是3 (2436×1125)。因此,需要将设备的规模设置为3。在CCDirectiorIOS.m的setContentScaleFactor中,您必须添加:
if([UIScreen mainScreen].scale == 3.0f)
__ccContentScaleFactor = 3;https://stackoverflow.com/questions/52531267
复制相似问题