Cocos拥有几种常规的事件例如:点击 鼠标移动 鼠标抬起 移出 键盘等
注册点击事件:
1:this.node.on("touchstart",回调函数,this)
2: this.node.on("mousestart",回调函数,this)
3: this.node.on(cc.node.EventType.TOUCH_START,回调函数,this)
注册移动事件:
1:this.node.on("touchmove",回调函数,this)
2: this.node.on("mousemove",回调函数,this)
3: this.node.on(cc.node.EventType.TOUCH_MOVE,回调函数,this)
注册鼠标抬起事件:
1:this.node.on("touchend",回调函数,this)
2: this.node.on("mouseend",回调函数,this)
3: this.node.on(cc.node.EventType.TOUCH_END,回调函数,this)
注册鼠标按下移出节点事件:
1:this.node.on("touchcancel",回调函数,this)
2: this.node.on("mousecancel",回调函数,this)
3: this.node.on(cc.node.EventType.TOUCH_CANCEL,回调函数,this)
注册键盘按下事件:
1: cc.systemEvent.on("keydown",回调函数,this)
删除事件
this.onde.off()