微信数据域中各种莫名其妙?高手请指点。 nodePool 无法使用,其他各种

微信数据域中各种莫名其妙?

  • Creator 版本:2.2.2

  • 目标平台: 微信

  • 详细报错信息,包含调用堆栈:

VM7873:1 Uncaught (in promise) gameSubContextThirdScriptError
Cannot set property ‘active’ of undefined
TypeError: Cannot set property ‘active’ of undefined
at RankingView.clearItemNode (http://127.0.0.1:52995/game/colorBallup_ranking/src/project.dev.js:578:27)
at RankingView. (http://127.0.0.1:52995/game/colorBallup_ranking/src/project.dev.js:476:22)
at step (http://127.0.0.1:52995/game/colorBallup_ranking/src/project.dev.js:398:23)
at Object.next (http://127.0.0.1:52995/game/colorBallup_ranking/src/project.dev.js:342:18)
at http://127.0.0.1:52995/game/colorBallup_ranking/src/project.dev.js:316:71
at new Promise ()
at __awaiter (http://127.0.0.1:52995/game/colorBallup_ranking/src/project.dev.js:296:14)
at RankingView.ranking (http://127.0.0.1:52995/game/colorBallup_ranking/src/project.dev.js:471:16)
at Function. (http://127.0.0.1:52995/game/colorBallup_ranking/src/project.dev.js:447:21)
at E. (http://127.0.0.1:52995/game/dev/WAGameSubContext.js:2:132813)

  • 重现方式:

  • 之前哪个版本是正常的 :

  • 手机型号 :

  • 手机浏览器 :

  • 编辑器操作系统 :

  • 编辑器之前是否有其它报错 :

  • 出现概率:

  • 额外线索:

#问题一 node 的 active undefined。 如果直接循环回收。一些子node 无法回收。所以才搞了: nodes[i].active=false;

这个问题,应该是 你对应的node是null吧

关键是:直接 undefined 就让人忍无可忍了

对啊,node是null,所以undefined
你是不是在哪删掉了?

contentNode 中有3个 node 节点,无法回收。搞不懂。 就是微信数据域中。 总是 有一年个无法回收。

let sprite= node.getChildByName("photo").getComponent(cc.Sprite);

node.getChildByName(“photo”) 这句话时不时还为空。取不到到

private clearItemNode(){
var nodes= this.contentNode.children;
if(nodes.length<=0) return;
//它奶奶的总有一两个 children 无法回收
this.contentNode.removeAllChildren()
}

emmm
有点蒙···
你的目的是什么?
还有,最好是用destroy吧

你那是nodepool?

是的,使用 nodepool 有问题,只能全部删除了。 还有其他一些问题

            // 发消息给子域,必须要等待一段时间,否则报错
            this.scheduleOnce((dt) => wx.postMessage({ messageType: WXMsgType.ranking }), 0.25);
            this.wxSub = this.node.find("wxSub").getComponent(cc.WXSubContextView);
            this.wxSub.updateSubContextViewport();

#图像字体 为什么没有颜色呢? 难道少打包了什么吗?
#开发环境

#真机器

private clearItemNode(){
var nodes= this.contentNode.children;
if(nodes.length<=0) return;
for(let i = 0; i < nodes.length; i++){
this.itemNodePool.put(nodes[i]);
i–;//关键在于Node被回收后父节点子对象减少。i值未减,i++后超出父节点子对象长度
}
}

此为正解。在for循环使用对象池回收时,你i< nodes.length,这个nodes.length不是一个常量!!!!其实是在不停的递减的,但是你的i在不断增大,导致for循环实际没有执行最开始的nodes.length次。可以改为this.itemNodePool.put(nodes[0])解决。

你那个颜色是用富文本做的吧,开发数据域里面好像暂时不支持RichText,官网有说:

使用的是图片 字体