实例化一个预制体,
cc.loader.loadRes("./Prefab/Player", function (err, prefab) {
var newNode = cc.instantiate(prefab);
var PComponent = newNode.getComponent("Player");
PComponent.init();
this._player.addChild(newNode);
}.bind(this));
在Player组件的init()函数中设置定时器
init: function(idx){
this.schedule(function(dt){
cc.log(this.toString() + "Now Player ID:" + this.playerData.getPlayerID());
}.bind(this), 0.125)
},
期望是每实例化一个预制体,都能创建一个定时器, 现在的情况 貌似,定时器被覆盖, 只有最后一个, 也就是这里的日志, 只会输出最一个创建的 playerID. @panda


