49 lines
1.0 KiB
JavaScript
49 lines
1.0 KiB
JavaScript
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
closeBtn: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
qrBtn: {
|
|
default: null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
onLoad () {
|
|
let self = this;
|
|
this.closeBtn.on('click', function () {
|
|
self.node.removeFromParent(true);
|
|
})
|
|
},
|
|
|
|
start () {
|
|
this.startup = false;
|
|
this.qrBtn.on(cc.Node.EventType.TOUCH_START, this.onTouchBg, this);
|
|
this.qrBtn.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this);
|
|
},
|
|
|
|
// update (dt) {},
|
|
update(dt) {
|
|
if (this.startup) {
|
|
this.time += dt;
|
|
if (this.time > 1) {
|
|
this.onTouchEnd();
|
|
onfire.fire("longPressed", {target: 'qr_qq', val: ''});
|
|
}
|
|
}
|
|
},
|
|
onTouchBg(e) {
|
|
this.time = 0;
|
|
this.startup = true;
|
|
},
|
|
onTouchEnd(e) {
|
|
this.time = 0;
|
|
this.startup = false;
|
|
},
|
|
});
|