Jump to content

Issues when reloading page and loading bitmapFont


Jerorx
 Share

Recommended Posts

Hi,

I am writing a simple game, which works fine, and when testing it (on a local wamp webserver) I very often reload the page in Firefox (44.0.2) to see the effect of the changes I make. That worked like a charm until I started to load a bitmapFont. Now, almost every time I reload (but not always), my sprites don't load. But if I "reload" by just typing enter in address bar, then everything loads fine. It's very strange. If I remove the bitmapFont loading, then everything gets back to normal. Other than that, everything works fine, the fonts display properly (if I don't refresh the page, that is). I don't get any errors whatsoever. It's pretty annoying tough. Any ideas how to fix this?

Here is how I load my assets, just in case: (the order in which I load them doesn't seem to change anything to the issue).

 function preload(){
        game.load.bitmapFont('desyrel', 'assets/fonts/desyrel.png', 'assets/fonts/desyrel.xml');
        game.load.spritesheet('blocks','assets/blocks.png',blockSize,blockSize,nbBlockTypes+1);
    }

 

 

Link to comment
Share on other sites

Do you have this same problem on other browsers?  This is pretty strange.

It might be some kind of caching issue...

You can try doing something like this to block any kind of browser caching:

 function preload(){
     game.load.bitmapFont('desyrel', 'assets/fonts/desyrel.png?' + Date.now(), 'assets/fonts/desyrel.xml?' + Date.now());
     game.load.spritesheet('blocks','assets/blocks.png?' + Date.now(),blockSize,blockSize,nbBlockTypes+1);
 }

Problem with that is the user is always going to have to download all the assets each time they play the game.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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