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

Window.Global里面存的node 为啥在切换scene后properties里面值被清空了?

$
0
0

@loseleo 写道:

//定义
var OManager = cc.Class({
extends: cc.Component,
properties: {
listener: null
},

// use this for initialization
onLoad: function () {
    this.listener = new Map();
    Global.oManager = this;
    
},

registListener: function (name, listener) {
this.listener.put(name, listener);
},
});

//全局
window.Global = {
oManager: null,
};

在initscene中加载了这个OManager脚本,然后initscene 切换场景到mainscene
mainscene中调用
Global.oManager.registListener("MainScene",function(event,data){});
调用是成功的,但是registListener中this.listener 为null了,请问为什么?需要把变量拿到外面做全局变量才行吗?

帖子: 5

参与者: 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>