Jump to content

Load images from Browser Cache?


ErikAtMapache
 Share

Recommended Posts

Hello all.

 

I've been researching this but haven't found an answer. I'm building a game that has two steps -- a login page and a game page. I'd like to preload the LoadingBackground image via javascript (while in the login page) before the game starts up so that the user doesn't get an ugly empty box while the image is loading. Is there a way to use an image that is in the browser's cache for a sprite instead of using game.load.image()?

 

Thanks for your time.

Erik 

Link to comment
Share on other sites

I've tried several different things but I'm not clear what you put in for the URL. The closest I got was creating a canvas on the page and calling canvas.toDataURL() but that seemed kind of iffy.

 

Your suggestion is greatly appreciated.

 

Erik

Link to comment
Share on other sites

My understanding is, literally, the URL. But I haven't tried it so I'm not sure.

 

There's a setting in Chrome's dev tools to not cache anything. Make sure that's not checked, i.e. you WANT to cache everything. Stick an <img> tag with a path to the image in your login page then, in your game, don't load the image, just add it to the cache by that same path as in the <img> tag... it SHOULD work.

 

Or, honestly, that's how I think it should work. ;p

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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