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

使用setNotificationNode无法屏蔽触摸事件

$
0
0

@piking881 写道:

创建一个NotificationLayer,里面吞掉了触摸事件,但是挂到NotificationNode上时,下面的Layer还是可以接收到消息,请问有什么解决方案能屏蔽掉触摸么

var NotificationLayer = cc.Layer.extend({

_touchListener: null,

onEnter: function () {
    if (this._touchListener == null) {
        this._touchListener = cc.EventListener.create({
            event: cc.EventListener.TOUCH_ONE_BY_ONE,
            swallowTouches: true,
            onTouchBegan: this.onTouchBegan,
            onTouchMoved: this.onTouchMoved,
            onTouchEnded: this.onTouchEnded
        });
    }
    cc.eventManager.addListener(this._touchListener, this);

},

onExit: function () {
    cf.removeListener(this._touchListener);
},

onTouchBegan: function (touch, event) {
    return true;
},
onTouchMoved: function (touch, event) {
},
onTouchEnded: function (touch, event) {
}

});

帖子: 1

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