大概的代码是这样的
理论上当鼠标点击,isStart变为true,但是update的 cc.log依然输出false…
cc.Class({
extends: cc.Component,
properties: {
isStart:false,
},
onLoad: function () {
this.node.on(cc.Node.EventType.MOUSE_UP, this.onMouseUP, this.node);
},
update: function (dt) {
cc.log(this.isStart);
},
onDestroy () {
this.node.off(cc.Node.EventType.MOUSE_UP, this.onMouseUP, this.node);
},
onMouseUP: function (event) {
this.isStart = true;
},
});