Jump to content

Keep cache from one state to another?


ForgeableSum
 Share

Recommended Posts

Is there a way to prevent Phaser from destroying the cache when going from 1 game state to another? I already tried:

game.cache.destroy = null;

 

I also tried setting clearWorld and clearCache (internal booleans) to false when starting the new state:

game.state.start("New State",false,false); 

 

And yet, the cache still gets wiped. I tried going through every instance (in Phaser) of cache.destroy and commenting it out ... yet still the cache does not carry over from 1 state to the next!

Link to comment
Share on other sites

Yes, the game assets cache, e.g. game.cache._images. game.cache._json, etc. When you say "i know that works" are you saying that the cache does not automatically be destroyed when you go from one cache to another? What works? When I mean states, I don't mean going from preload to create, etc inside of a single state. I mean going from one state to a complete different state. I want one state to have access to the assets loaded in the preload of another state. 

Link to comment
Share on other sites

Yes, sorry, I meant "moving from one state to another does not empty the asset cache". My game, running Phaser 2.4.4, preloads in one state, has a main menu in a second, then plays in a third... all using assets loaded in the first preload state.

 

I'm kind of at a loss as to why that's happening for you, especially if you're commenting out all the "empty" and "destroy" methods and it's still happening. Can you make it happen in a minimal example on codepen or jsbin or something?

Link to comment
Share on other sites

Yes, sorry, I meant "moving from one state to another does not empty the asset cache". My game, running Phaser 2.4.4, preloads in one state, has a main menu in a second, then plays in a third... all using assets loaded in the first preload state.

 

I'm kind of at a loss as to why that's happening for you, especially if you're commenting out all the "empty" and "destroy" methods and it's still happening. Can you make it happen in a minimal example on codepen or jsbin or something?

Please see my comment here: http://www.html5gamedevs.com/topic/18995-webgl-invalid-image-error/#entry108664

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...