onEnable: function () {
this.node.on('touchstart', function (event) {
event.stopPropagation();
this.node.on('touchend', function (event) {
event.stopPropagation();
onDisable: function () {
this.node.off('touchstart', function (event) {
event.stopPropagation();
this.node.off('touchend', function (event) {
event.stopPropagation();
我使用this.node.on(‘touchstart’, function (event) {也不能吞噬触摸事件,另外找到一个方法:
var listener = cc.EventListener.create({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
onTouchBegan: function (touch, event) {
cc.log('Touch Began: ’ + event);
event.stopPropagation();
return false;
cc.eventManager.addListener(listener, this.node);
可行,你可以试试。
请问这两种方式实现机制有什么不同,为什么一种可以,另一种不行?