你的位置:

荔枝笔记

/

cocos creator 全局获取手指是否按下状态

cc.Class({
extends: cc.Component,

properties: {
    isTouchDown: false,
},

onLoad () {
    cc.systemEvent.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
    cc.systemEvent.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
    cc.systemEvent.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
},

onDestroy () {
    cc.systemEvent.off(cc.Node.EventType.TOUCH_START, this.onTouchStart, this);
    cc.systemEvent.off(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
    cc.systemEvent.off(cc.Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
},

onTouchStart (event) {
    this.isTouchDown = true;
},

onTouchEnd (event) {
    this.isTouchDown = false;
},

});


标签:

你的位置:

荔枝笔记

/