I am not able to remove spine animation from PIXI.Container.
As soon as i removeChild it, it throws an error.
Please help.
Below is the code :
private testSpineAnimation(): void {
const resource = App.loader.resources.gfx['dice_Anim_1to5'];
const animation = new Spine(resource.spineData);
this.allSpineAnims = [];
this.allSpineAnims.push(animation);
// add the animation to the scene and render...
this.baseContainer.addChild(animation);
if (animation.state.hasAnimation('animation')) {
animation.scale.set(0.5);
animation.position.set(152, 552);
animation.state.addListener({
start: () => {
console.log("ANIMATION START");
},
end: () => {
console.log("ANIMATION END");
},
complete: (entry: ITrackEntry) => {
this.clearAndRemoveSpineAnimations();
}
});
// run forever, little boy!
animation.state.setAnimation(0, 'animation', false);
// dont run too fast
// animation.state.timeScale = 0.1;
// update yourself
animation.autoUpdate = true;
}
}
private clearAndRemoveSpineAnimations() : void {
for (let anim of this.allSpineAnims) {
anim.autoUpdate = false;
anim.state.clearTracks();
this.baseContainer.removeChild(anim);
}
}
I am not able to remove spine animation from PIXI.Container. As soon as i removeChild it, it throws an error.
Please help. Below is the code :
private testSpineAnimation(): void { const resource = App.loader.resources.gfx['dice_Anim_1to5']; const animation = new Spine(resource.spineData); this.allSpineAnims = []; this.allSpineAnims.push(animation); // add the animation to the scene and render... this.baseContainer.addChild(animation);