触摸事件
假设给整个Canvas添加了事件监听。用网页模拟时,鼠标移动,点击子node都会监听到。
start() {
this._cfgTouchField();
}
_onTouchFieldDown(e) {
cc.log('table', '_onTouchFieldDown');
}
_onTouchFieldMove(e) {
cc.log('table', '_onTouchFieldMove');
}
_onTouchFieldEnd(e) {
cc.log('table', '_onTouchFieldEnd');
}
_cfgTouchField() {
this.node.on(cc.Node.EventType.MOUSE_DOWN, this._onTouchFieldDown, this);
this.node.on(cc.Node.EventType.MOUSE_MOVE, this._onTouchFieldMove, this);
this.node.on(cc.Node.EventType.MOUSE_LEAVE, this._onTouchFieldEnd, this);
this.node.on(cc.Node.EventType.MOUSE_UP, this._onTouchFieldEnd, this);
}
网页模拟,鼠标从空白地方移入Toggle的范围时,会触发一次cc.Node.EventType.MOUSE_LEAVE
;
然后又是cc.Node.EventType.MOUSE_MOVE