this.node.on event修改变量,update()获取不到?

大概的代码是这样的
理论上当鼠标点击,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;
    },
});

因为你 on 事件第三个参数传错了,应该传 this,而不是 this.node,导致 onMouseUp 里面的 this 变成了 this.node

确实的写法

this.node.on(cc.Node.EventType.MOUSE_UP, this.onMouseUP, this);