/**
* Author:W
* 鼠标事件
*/
cc.Class({
extends: cc.Component,
properties: {
},
// onLoad () {},
start () {
this.node.on(cc.Node.EventType.MOUSE_DOWN,function(event){
cc.log("鼠标在目标节点区域按下时");
});
this.node.on(cc.Node.EventType.MOUSE_ENTER,function(event){
cc.log("当鼠标移入目标节点区域时,无论是否按下");
});
this.node.on(cc.Node.EventType.MOUSE_MOVE,function(event){
cc.log("当鼠标在目标区域移动时,无论是否按下");
});
this.node.on(cc.Node.EventType.MOUSE_LEAVE,function(event){
cc.log("当鼠标移出目标节点区域时,不论是否按下");
});
this.node.on(cc.Node.EventType.MOUSE_UP,function(event){
cc.log("当鼠标从按下状态松开时");
});
},
onDestroy()
{
this.node.off(cc.Node.EventType.MOUSE_DOWN,function(event){
});
this.node.off(cc.Node.EventType.MOUSE_ENTER,function(event){
});
this.node.off(cc.Node.EventType.MOUSE_MOVE,function(event){
});
this.node.off(cc.Node.EventType.MOUSE_LEAVE,function(event){
});
this.node.off(cc.Node.EventType.MOUSE_UP,function(event){
});
}
// update (dt) {},
});
鼠标事件监听注册
最新推荐文章于 2022-12-03 22:07:24 发布