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;