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;