Hello! I have a Class named CoinEffect which I created each time a player do a combo in my game. This Class contained several GUI element such as images, textblocks…
All GUI element in this Class are animated on the runtime (position, scale, rotation, alpha…). When the animation is done, I want all the GUI element to be destroy.
What is the better way to remove/destroy GUI element from a scene ?
Pseudo code below - which one is the solution and/or is there a better way to avoid any memory issue at long term?
// Remove object
public disposeUI(): void {
this.listUIElement.forEach((object: any) => {
this.app.gameUI.removeControl(object); // #1
object.dispose(); // #2
object = null; // #3
});
// Clear array
this.listUIElement = [];
}