enerateNode: function () {
var monster = this._pool.get();
if (!monster) {
monster = cc.instantiate(this.prefab);
// Add pool handler component which will control the touch event
monster.addComponent(‘PoolHandler’);
}
monster.x = this.regionOrigin.x + Math.floor(Math.random() * this.regionSize.width);
monster.y = this.regionOrigin.y + Math.floor(Math.random() * this.regionSize.height);
var angle = Math.random() * Math.PI * 2;
var dx = 500 * Math.cos(angle);
var dy = 500 * Math.sin(angle);
monster.runAction(cc.sequence(
cc.moveBy(5, dx, dy),
cc.callFunc(**this.removeNode**, this, monster) //这里面的回调函数没有传参数
));
this.node.addChild(monster);
},
removeNode: function (sender, monster) { //这里面传了参数,请问是怎么实现的?
this._pool.put(monster); //
console.log(sender);// 这个是monsterPreFab
console.log(monster);//这个也是monsterPreFab, 并没有指定实参, 为什么会有参数传进来?为啥都一样?既然一样,为什么要传两个参数?是不是文档里面还有没有说明的地方?问题太多了啊。