P. Frank
P. Frank

Reputation: 5745

Phaser - Clean loadState and bootState cache DOM

I have a game make with Phaser.js. I would like to clean all loadState and bootState cache DOM, for remove image link.

I use actually Phaser.Cache for remove all cache in Game DOM, it work but the loadState and bootState cache still there.

When i use Phaser.Cache

game.cache = new Phaser.Cache(game);
game.load.reset();
game.load.removeAll();

The Game cache result is cleaned

image Object { __default={...}, __missing={...}} __default Object { key="__default", data=img, base={...}, plus...} __missing Object { key="__missing", data=img, base={...}, plus...}

But the loadStateand bootState cache is still there

image Object { __default={...}, __missing={...}, background2={...}, plus...} __default Object { key="__default", data=img, base={...}, plus...} __missing Object { key="__missing", data=img, base={...}, plus...} background Object { key="background", url="data:image/jpeg;base64,/...q0xYqtMOKrDFiqz0sVf/9k=", data=img, plus...}

Upvotes: 1

Views: 374

Answers (1)

Shohanur Rahaman
Shohanur Rahaman

Reputation: 387

you need to clear each state

game.state.clearCurrentState(); 

The phaser doc says :

This method clears the current State, calling its shutdown callback. The process also removes any active tweens, resets the camera, resets input, clears physics, removes timers and if set clears the world and cache too.

you can also use

game.state.destroy(); // Removes all StateManager callback references to the State object, nulls the game reference and clears the States object

Upvotes: 1

Related Questions