From 95259b25d66f8842b29b5ea2331682ac5949dca9 Mon Sep 17 00:00:00 2001 From: tiendat3699 <96950844+tiendat3699@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:16:55 +0700 Subject: [PATCH] chore --- assets/_Game/Scripts/Environments/ScoreObject.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/assets/_Game/Scripts/Environments/ScoreObject.ts b/assets/_Game/Scripts/Environments/ScoreObject.ts index 513782f..1ac6881 100644 --- a/assets/_Game/Scripts/Environments/ScoreObject.ts +++ b/assets/_Game/Scripts/Environments/ScoreObject.ts @@ -40,12 +40,10 @@ export class ScoreObject extends Component implements IPoolable { private _originColor: Color; private _isHit = false; - private _colliderEnabled: boolean = true; - protected onLoad(): void { this._collider.on(Contact2DType.BEGIN_CONTACT, this.onContactBegin, this); this._originColor = this._sprite.color.clone(); - this._colliderEnabled = false; + this._collider.enabled = false; } protected update(dt: number): void { @@ -68,9 +66,9 @@ export class ScoreObject extends Component implements IPoolable { } private async onContactBegin(selfCollider: Collider2D, otherCollider: Collider2D) { - if (!this._colliderEnabled) return; + if (!this._collider.enabled) return; if (this._isHit) return; - this._colliderEnabled = false; + this._collider.enabled = false; if (this._hitSound) AudioManager.playSfx(this._hitSound); // let center = this.node.getWorldPosition(); // let other = otherCollider.node.getWorldPosition(); @@ -91,12 +89,12 @@ export class ScoreObject extends Component implements IPoolable { public async onGet() { this._animation.play(this._animation.clips[0].name); await Utils.delay(this._animation.clips[0].duration); - this._colliderEnabled = true; + this._collider.enabled = true; } public onRelease() { this._isHit = false; - this._colliderEnabled = false; + this._collider.enabled = false; this.node.angle = 0; this.node.setScale(Vec3.ONE); this._sprite.color = this._originColor;