From b644e0e0ab790eaf5b0dc541797f9fb5d86ab5a6 Mon Sep 17 00:00:00 2001 From: JianMiau Date: Sun, 8 May 2022 13:29:13 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20HoldButton=20=E9=BB=9E=E6=93=8A?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E8=A1=9D=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Engine/Component/Button/HoldButton.ts | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/assets/Script/Engine/Component/Button/HoldButton.ts b/assets/Script/Engine/Component/Button/HoldButton.ts index 2f6de2a..6171a5a 100644 --- a/assets/Script/Engine/Component/Button/HoldButton.ts +++ b/assets/Script/Engine/Component/Button/HoldButton.ts @@ -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;