mirror of
https://gitee.com/dgflash/oops-plugin-framework.git
synced 2026-05-30 18:39:18 +08:00
修复动画效果回收失败问题
This commit is contained in:
@@ -100,9 +100,6 @@ class GameNodePool {
|
||||
node.removeFromParent();
|
||||
}
|
||||
|
||||
// 重置节点状态
|
||||
node.active = false;
|
||||
|
||||
// 回收到池中
|
||||
pool.put(node);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user