Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88737

CocosCreator使用cocos2d-js的适配方案

$
0
0

@_boy1 写道:

前言

在CocosCreator中提供了Canvas的屏幕适配解决方案。
- Fit Height 按照高等比缩放
- Fit Width 按照宽等比缩放

这样保证了游戏内容的比例显示正确,不过难免会存在黑边,用户体验上真是很难接受

放弃Canvas 使用CocosJs的适配

  • 要在每一个Scene下挂载的一个脚本
  • 在脚本的onLoad中加入如下的语句 即可实现拉伸全屏
  • 要勾选掉Fit Height和Fit Width

cc.view.setDesignResolutionSize(768, 1280, 0);

ResolutionExactFit 的值为0 以下类推

下面是适配参数的解释

  • [1] ResolutionExactFit Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.
  • [2] ResolutionNoBorder Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.
  • [3] ResolutionShowAll Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.
  • [4] ResolutionFixedHeight Scale the content's height to screen's height and proportionally scale its width
  • [5] ResolutionFixedWidth Scale the content's width to screen's width and proportionally scale its height
  • [cc.ResolutionPolicy] [Web only feature] Custom resolution policy, constructed by cc.ResolutionPolicy

PS

  • 比较优选的是ResolutionNoBorder值为1
  • 适配的更改不会影响widget的使用
  • 可以对多个scene配置不同的适配方案

本文地址:http://allknowboy.com/posts/b66946d7/

帖子: 1

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>