CocosCreator按钮触摸事件

CocosCreator按钮触摸事件绑定代码
脚本绑定在Button上

onLoad() {
        this.node.on(cc.Node.EventType.TOUCH_START, function (event) {
            cc.log("TOUCH_START event=", event.type);
        });

        this.node.on(cc.Node.EventType.TOUCH_MOVE, function (event) {
            cc.log("TOUCH_MOVE event=", event.type);
        });

        this.node.on(cc.Node.EventType.TOUCH_END, function (event) {
            cc.log("TOUCH_END event=", event.type);
        });
    }

Button是属性的情况

 properties: {
  	Button:cc.Node,
  ...
  }
onLoad() {
	if (this.Button) {
	        this.Button.on(cc.Node.EventType.TOUCH_END, event => {
            cc.log("TOUCH_END event=", event.type);
	        }, this);
	      }
}

你可能感兴趣的:(CocosCreator按钮触摸事件)