android适配:
参考资料:http://developers.googleblog.cn/2017/04/android.html
在AndroidManifest.xml中可做如下配置:
<meta-data android:name="android.max_aspect" android:value="2.1" />
然后在代码中设置适配方式(我采用的设置条件是width/height>1.8):
ios(针对iphoneX)适配:
首先参考https://blog.youkuaiyun.com/auccy/article/details/80774845设置iphoneX的LaunchImage
然后修改AppController.mm中创建window的代码为:
CGRect rect=[[UIScreen mainScreen] bounds];
if(rect.size.width==812
&&rect.size.height==375)
{
rect.origin.x+=32;
rect.size.width-=64;
}
_window = [[UIWindow alloc] initWithFrame: rect];
代码的作用是,左右两侧各留32像素的黑边,防止游戏内容被刘海遮住。