Jump to content

question about cdn loader in phaser


scofieldly
 Share

Recommended Posts

Hi guys, 

 

I am using phaser to dev a game, currently I got a problem that, I want to deploy my assets resource on a cdn, so I need to make a resource loader for these assets.

 

the basic logic is that firstly I will start fetch the resource from cdn, after serval seconds, if I can not get the resource, I will switch the way to get the assets from local.

 

for the phaser, I do not know how to check if 
game.load.image/ game.load.atlasJSONHash can get the corresponding resource.

so is there anyone have idea how should I handle this, thx.

Link to comment
Share on other sites

Use Loader.onFileError and listen for that. Although I strongly recommend you do a test CDN load of just one file, and if that one file fails, you load everything else locally. Otherwise you'll spam the browser with network errors, or similar. Also, what kind of CDN would fail to respond after several seconds?! Sounds like a pretty poor one :)

Link to comment
Share on other sites

3 hours ago, rich said:

Use Loader.onFileError and listen for that. Although I strongly recommend you do a test CDN load of just one file, and if that one file fails, you load everything else locally. Otherwise you'll spam the browser with network errors, or similar. Also, what kind of CDN would fail to respond after several seconds?! Sounds like a pretty poor one :)

thanks for your reply rich,

yes, this CDN has some chance for have a big delay, currently I find the function onFileStart in the loader, so I think I can use it to do the 'timer', logic, bug actually I want to ask is there any way that I can stop a file loading process, thanks.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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