[转]cocos2d-js 3.0 屏幕适配方案 分辨率适应
首先介绍一个api和相应的参数:
cc.view.setDesignResolutionSize(1024, 768, cc.ResolutionPolicy.FIXED_WIDTH);
这里设置游戏制作的目标尺寸和显示的模式。
模式包括:
cc.ResolutionPolicy = {// 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,// 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,// 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,// 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 ratiosFIXED_HEIGHT:3,// The application takes the width of the design resolution size and modifies the height 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 ratiosFIXED_WIDTH:4,UNKNOWN:5 };
参考官方说明: 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,其他用法请参考:
转自:http://www.cnblogs.com/kenkofox/p/3951210.html
作者还推荐了腾讯的面试机会,具体见上一行这个链接。
[转]cocos2d-js 3.0 屏幕适配方案 分辨率适应相关推荐
- Cocos2d-js 3.0 屏幕适配方案 分辨率适应
首先介绍一个api和相应的参数: cc.view.setDesignResolutionSize(1024, 768, cc.ResolutionPolicy.FIXED_WIDTH); 这里设置游戏 ...
- 超详细的rem+vw移动端屏幕适配方案
在说具体内容之前,我们必须了解几个概念,就是:Retina屏.物理像素.设备独立像素.设备像素比 在CSS中我们一般使用px作为单位,需要注意的是,CSS样式里面的px和物理像素并不是相等的.CSS中 ...
- 安卓屏幕适配方案(根据今日头条方案,升级版)
前言 屏幕适配方案有很多,比如原生的dp,鸿洋大神的AutoLayout,宽高限定符,今天我用缺点比较小的今日头条方案 头条适配方案的文章链接:https://mp.weixin.qq.com/s/d ...
- 今日头条屏幕适配方案落地研究
目录 前言 各平板数据比较 为什么看起来更小了?(头条方案跟最小宽度方案比较) smallesWidth 方案迁移 优缺点 issue 附录(适配核心代码) 前言 大家好,现在给大家推荐一种极低版本的 ...
- 11-Flutter移动电商实战-首页_屏幕适配方案和制作
11-Flutter移动电商实战-首页_屏幕适配方案和制作 1.flutter_ScreenUtil插件简介 flutter_ScreenUtil屏幕适配方案,让你的UI在不同尺寸的屏幕上都能显示合理 ...
- android屏幕适配教程,Android屏幕适配方案,android屏幕适配
Android屏幕适配方案,android屏幕适配 文章转载禁止用于商业用途,且不能带有虚拟货币.积分.注册等附加条件.转载须注明出处莫高雷草原以及作者@JiongBull. Android屏幕适配方 ...
- Cocos2d-html5 2.2.2的屏幕适配方案
来自:http://www.cocos2d-x.org/docs/manual/framework/html5/resolution-policy-design/zh 关于屏幕适配 作为WEB开发者, ...
- 2021年最详细的Android屏幕适配方案汇总
1 Android屏幕适配的度量单位和相关概念 建议在阅读本文章之前,可以先阅读快乐李同学写的文章<Android屏幕适配的度量单位和相关概念>,这篇文章包含了阅读本文的一些基础知识,推荐 ...
- android smallestWidth 限定符屏幕适配方案dimens.xml
简介 smallestWidth 限定符适配方案 这个方案的的使用方式和我们平时在布局中引用 dimens 无异,核心点在于生成 dimens.xml 文件,但是已经有大神帮我们做了这 一步 ├── ...
最新文章
- 第7章——狄克特斯拉算法
- 【ASP.NET开发】ASP.NET(MVC)三层架构知识的学习总结
- 介绍几本专业的书籍,一起学习
- 只用最适合的! 全面对比主流 .NET 报表控件:水晶报表、FastReport、ActiveReports 和 Stimulsoft...
- C语言编译报错:incompatible pointer type [-Wincompatible-pointer-types](传参类型不匹配)
- 亿级流量网站架构核心技术_关于大型网站系统架构你不得不懂的10个问题
- 160 - 5 ajj.2
- LeetCode MySQL 614. 二级关注者
- JS删除两个数组中相同的某个对象值
- python教学查询,python基础教程之查询集 QuerySet和管理器Manager
- 系统性能调优的各个方面
- 猜数字游戏PYS60版代码分享啦
- 武魂java_js及jsp.java查错的几种方式
- 原生js的JSONP跨域请求
- 软件开发的能力体系及锻炼
- MySql基础篇——变量、流程控制与游标
- 从“为什么创业”到“怎么创业”(转)
- python:错误:TypeError: string argument without an encoding;str() takes at most 1 argument
- 现代计算机之父—冯·诺依曼
- IT项目管理之软件测试
热门文章
- SDT(software-defined Things)?软件定义的物件
- 另辟蹊径创建移动应用:iOS和Android代码共享
- linux 内核参数调整说明
- 型网站的架构设计问题----大型高并发高负载网站的系统架构
- 高性能的MySQL(6)查询慢与重构查询
- [Python]小百合十大爬虫
- Codeforces Round #FF 446 C. DZY Loves Fibonacci Numbers
- C#_uploadify_mvc_version
- 劣质代码评析——《写给大家看的C语言书(第2版)》附录B之21点程序(一)
- as一种模拟输入效果