第一次cc.director.runScene(new PlayScene());,精灵触摸事件能调用
游戏结束后,第二次执行: cc.director.runScene(new PlayScene());
则触摸精灵没反应了,请问可能是什么原因造成的呢? 而且游戏结束后也把监听都remove掉了
this.touchListener = cc.EventListener.create({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
// When “swallow touches” is true, then returning ‘true’ from the onTouchBegan method will “swallow” the touch event, preventing other listeners from using it.
swallowTouches: true,
//onTouchBegan event callback function
onTouchBegan: function (touch, event) {
cc.log(“touched”);
//only first user can click
var target = event.getCurrentTarget();
if(layer.bombUser.index!=0 || target.index==0) return false;
var pos = touch.getLocation();
if (cc.rectContainsPoint(target.getBoundingBox(), pos)) {
cc.log(“touched”);
layer.goNext(target);
return true;
}
return false;
}
});
for(var i=0;i<this.userCount;i++) {
console.log('listener '+i+" ok");
this.users*.listener= cc.eventManager.addListener(this.touchListener.clone(), this.users【i】);
}*