写在前面,本帖记录为主,如果新版已经修复,请忽略。。。
1、屏幕顶部或者右侧出现的小黑边(个位像素的宽度)(SHOW_ALL适配策略)
cc.view.setDesignResolutionSize(720, 1280, cc.ResolutionPolicy.SHOW_ALL);
效果如图:
强迫症不能忍,原因就不细究了,解决方法如下:
var policy = new cc.ResolutionPolicy(cc.ContainerStrategy.PROPORTION_TO_FRAME,cc.ContentStrategy.EXACT_FIT);
cc.view.setDesignResolutionSize(720, 1280, policy);
2、removeAllChildren方法失效
查看对象属性发现数组已经清空但是没有触发dirty check
解决方法如下,修改CCNode.js下removeAllChild方法
removeAllChildren: function (cleanup) {
// not using detachChild improves speed here
var __children = this._children;
if (__children != null) {
if (cleanup == null)
cleanup = true;
for (var i = 0; i < __children.length; i++) {
var node = __children;
if (node) {
// IMPORTANT:
// -1st do onExit
// -2nd cleanup
if (this._running) {
node.onExitTransitionDidStart();
node.onExit();
}
if (cleanup)
node.cleanup();
// set parent nil at the end
node.parent = null;
}
}
this._children.length = 0;
this.setNodeDirty();
cc.renderer.childrenOrderDirty = true;
}
}
添加的只有最后两行:
this.setNodeDirty();
cc.renderer.childrenOrderDirty = true;
3、一个不算bug的bug,适配有时候不能全屏
效果如图:
html示意如下:
<body>
<canvas id="gameCanvas" width="720" height="1280"></canvas>
</body>
修改方案很简单:
<style>
body {overflow: hidden;}
</style>
4、chrome手机模拟会报错
head标签添加:
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale = 1,user-scalable = 0"/>
刚学cocos,有理解不对的地方欢迎讨论。。