大佬教程收集整理的这篇文章主要介绍了cocos2d-js 3.0 屏幕适配方案 分辨率适应,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
首先介绍一个api和相应的参数:
cc.view.setDesignResolutionSize(1024,768,cc.ResolutionPolicy.FIXED_WIDTH);
这里设置游戏制作的目标尺寸和显示的模式。
模式包括:
cc.ResolutionPolicy =@H_262_23@ { // The entire application is visible in the specified area without trying to preserve the original aspect ratio. Distortion can occur,and the application may appear stretched or compressed. EXACT_FIT:0@H_262_23@, The entire application fills the specified area,without distortion but possibly with some cropping, while maintaining the original aspect ratio of the application. NO_BORDER:1@H_262_23@,0); line-height:1.5!important"> The entire application is visible in the specified area without distortion while maintaining the original aspect ratio of the application. Borders can appear on two sides of the application. SHOW_ALL:2@H_262_23@,0); line-height:1.5!important"> The application takes the height of the design resolution size and modifies the width of thE internal canvas so that it fits the aspect ratio of the device no distortion will occur however you must make sure your application works on different aspect ratios FIXED_HEIGHT:3@H_262_23@,0); line-height:1.5!important"> The application takes the width of the design resolution size and modifies the height of thE internal aspect ratios FIXED_WIDTH:4@H_262_23@,UNKNOWN:5@H_262_23@ };
参考官方说明:http://www.cocos2d-x.org/wiki/Multi_resolution_support
EXACT_FIT会拉伸游戏,充满整个屏幕,最简单最粗暴;
SHOW_ALL保持游戏原比例,让一边占满屏幕,另外一侧黑边;
NO_BORDER跟SHOW_ALL类似,但让短边占满屏幕,另外一侧超出屏幕,不显示黑边,一部分画面在屏幕外,无法显示;
FIXED_WIDTH和FIXED_HEIGHT都是NO_BORDER的升级版,指定那一侧充满屏幕,另外一侧超出屏幕。
这里建议使用FIXED_WIDTH和FIXED_HEIGHT,其他用法请参考:
以上是大佬教程为你收集整理的cocos2d-js 3.0 屏幕适配方案 分辨率适应全部内容,希望文章能够帮你解决cocos2d-js 3.0 屏幕适配方案 分辨率适应所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。