[fix] HoldButton 點擊事件衝突
This commit is contained in:
parent
6bc14bc92a
commit
b644e0e0ab
@ -36,6 +36,8 @@ export default class HoldButton extends cc.Component {
|
||||
|
||||
private _m_pressDeltaTime: number = 0;
|
||||
|
||||
private _scale: cc.Vec3 = null;
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Lifecycle
|
||||
@ -44,6 +46,7 @@ export default class HoldButton extends cc.Component {
|
||||
if (this.HoldLine != null) {
|
||||
this.HoldLine.active = false;
|
||||
}
|
||||
this._scale = this._scale;
|
||||
}
|
||||
|
||||
protected update(dt: number): void {
|
||||
@ -58,13 +61,13 @@ export default class HoldButton extends cc.Component {
|
||||
|
||||
protected onEnable(): void {
|
||||
this.node.on(cc.Node.EventType.TOUCH_START, this._onTouchStart, this);
|
||||
this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnd, this);
|
||||
this.node.on(cc.Node.EventType.TOUCH_END, this._onTouchCancel, this);
|
||||
this.node.on(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancel, this);
|
||||
}
|
||||
|
||||
protected onDisable(): void {
|
||||
this.node.off(cc.Node.EventType.TOUCH_START, this._onTouchStart, this);
|
||||
this.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnd, this);
|
||||
this.node.off(cc.Node.EventType.TOUCH_END, this._onTouchCancel, this);
|
||||
this.node.off(cc.Node.EventType.TOUCH_CANCEL, this._onTouchCancel, this);
|
||||
}
|
||||
|
||||
@ -100,6 +103,8 @@ export default class HoldButton extends cc.Component {
|
||||
}
|
||||
});
|
||||
}
|
||||
this.node.active = false;
|
||||
this.node.active = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,17 +122,6 @@ export default class HoldButton extends cc.Component {
|
||||
}
|
||||
}
|
||||
|
||||
private _onTouchEnd(event: cc.Event.EventTouch): void {
|
||||
this.node.resumeSystemEvents(true);
|
||||
this._m_isMouseDown = false;
|
||||
this._m_pressDeltaTime = 0;
|
||||
if (this.IsHaveHoldLine) {
|
||||
this.HoldLine.active = false;
|
||||
}
|
||||
this._isOnInvoke = false;
|
||||
this._checkHoldAutoStart(0);
|
||||
}
|
||||
|
||||
private _onTouchCancel(event: cc.Event.EventTouch): void {
|
||||
this.node.resumeSystemEvents(true);
|
||||
this._m_isMouseDown = false;
|
||||
|
Loading…
Reference in New Issue
Block a user