From 4b9b05fa9f452448237a49b304bfebcecaf55a13 Mon Sep 17 00:00:00 2001 From: dgflash Date: Sat, 30 May 2026 06:50:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8A=A8=E7=94=BB=E6=95=88?= =?UTF-8?q?=E6=9E=9C=E5=9B=9E=E6=94=B6=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/core/common/pool/GameNodePool.ts | 3 --- assets/module/common/part/GamePartNodePool.ts | 5 ---- .../AnimationEffectAutoRelease.ts | 9 +++---- .../ParticleEffectAutoRelease.ts | 5 ++-- .../animator-effect/SpineEffectAutoRelease.ts | 27 +++++++++---------- 5 files changed, 17 insertions(+), 32 deletions(-) diff --git a/assets/core/common/pool/GameNodePool.ts b/assets/core/common/pool/GameNodePool.ts index 4f87c8c..1d375f5 100644 --- a/assets/core/common/pool/GameNodePool.ts +++ b/assets/core/common/pool/GameNodePool.ts @@ -100,9 +100,6 @@ class GameNodePool { node.removeFromParent(); } - // 重置节点状态 - node.active = false; - // 回收到池中 pool.put(node); } diff --git a/assets/module/common/part/GamePartNodePool.ts b/assets/module/common/part/GamePartNodePool.ts index a5326e8..c08e3ae 100644 --- a/assets/module/common/part/GamePartNodePool.ts +++ b/assets/module/common/part/GamePartNodePool.ts @@ -157,11 +157,6 @@ export class GamePartNodePool extends GamePartBase { if (comp) { // 设置自动回收 if (params.isPlayFinishedRelease) { - // @ts-ignore - if (node._oops_auto_release) return; - // @ts-ignore - node._oops_auto_release = true; - comp.onPlayComplete(() => this.put(node)); } comp.setSpeed(this._speed); diff --git a/assets/module/common/part/animator-effect/AnimationEffectAutoRelease.ts b/assets/module/common/part/animator-effect/AnimationEffectAutoRelease.ts index f0a3fb2..33f361d 100644 --- a/assets/module/common/part/animator-effect/AnimationEffectAutoRelease.ts +++ b/assets/module/common/part/animator-effect/AnimationEffectAutoRelease.ts @@ -6,9 +6,9 @@ const { ccclass } = _decorator; /** Cocos Animation动画自动释放组件 */ @ccclass('AnimationEffectAutoRelease') export class AnimationEffectAutoRelease extends Component implements IAutoRelease { - private callback: (() => void) | null = null; + private callback: Function | null = null; - onPlayComplete(callback: () => void): void { + onPlayComplete(callback: Function): void { this.callback = callback; } @@ -16,10 +16,7 @@ export class AnimationEffectAutoRelease extends Component implements IAutoReleas const anim = this.getComponent(Animation); if (anim) { anim.once(Animation.EventType.FINISHED, () => { - if (this.callback) { - this.callback(); - this.callback = null; - } + this.callback && this.callback(); }); anim.play(); } diff --git a/assets/module/common/part/animator-effect/ParticleEffectAutoRelease.ts b/assets/module/common/part/animator-effect/ParticleEffectAutoRelease.ts index 5ecccf0..07142f8 100644 --- a/assets/module/common/part/animator-effect/ParticleEffectAutoRelease.ts +++ b/assets/module/common/part/animator-effect/ParticleEffectAutoRelease.ts @@ -6,10 +6,10 @@ const { ccclass } = _decorator; /** 粒子动画自动释放组件 */ @ccclass('ParticleEffectAutoRelease') export class ParticleEffectAutoRelease extends Component implements IAutoRelease { - private callback: (() => void) | null = null; + private callback: Function | null = null; private timerId: number | null = null; - onPlayComplete(callback: () => void): void { + onPlayComplete(callback: Function): void { this.callback = callback; } @@ -24,7 +24,6 @@ export class ParticleEffectAutoRelease extends Component implements IAutoRelease this.timerId = setTimeout(() => { this.timerId = null; this.callback && this.callback(); - this.callback = null; }, duration) as unknown as number; } } diff --git a/assets/module/common/part/animator-effect/SpineEffectAutoRelease.ts b/assets/module/common/part/animator-effect/SpineEffectAutoRelease.ts index e4a82f4..064fbe7 100644 --- a/assets/module/common/part/animator-effect/SpineEffectAutoRelease.ts +++ b/assets/module/common/part/animator-effect/SpineEffectAutoRelease.ts @@ -6,29 +6,26 @@ const { ccclass } = _decorator; /** Spine动画自动释放组件 */ @ccclass('SpineEffectAutoRelease') export class SpineEffectAutoRelease extends Component implements IAutoRelease { - private callback: (() => void) | null = null; + private callback: Function | null = null; private spine: sp.Skeleton | null = null; - onPlayComplete(callback: () => void): void { + onPlayComplete(callback: Function): void { this.callback = callback; } play(): void { this.spine = this.getComponent(sp.Skeleton); - if (this.spine) { - this.spine.setCompleteListener(() => { - this.spine!.setCompleteListener(null!); - if (this.callback) { - this.callback(); - this.callback = null; - } - }); + if (!this.spine) return; - const json = (this.spine.skeletonData!.skeletonJson! as any).animations; - for (const name in json) { - this.spine.setAnimation(0, name, false); - break; - } + this.spine.setCompleteListener(() => { + this.spine!.setCompleteListener(null!); + this.callback && this.callback(); + }); + + const json = (this.spine.skeletonData!.skeletonJson! as any).animations; + for (const name in json) { + this.spine.setAnimation(0, name, false); + break; } }