cocos2d-js v3.1 bug记录

写在前面,本帖记录为主,如果新版已经修复,请忽略。。。
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,有理解不对的地方欢迎讨论。。

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值