Jump to content

pumuky
 Share

Recommended Posts

Hi, 

To make the preload faster, I need to load several assets after the preload phase, and use then when they has been loaded. To do that, I've used the Phaser.Loader object and register to "onFileComplete" Phaser.Signal to catch the file when has been loaded, to load the next file.

This works well until I need to change the current state and there are an asset being loaded. When the file is loaded and the new state has been created, Phaser detects that the Loader is not loading (processLoadQueue method from Phaser.loader) and shows this message: 'Phaser.Loader - active loading canceled / reset', and the "onFileComplete" registered functions, are not fired, and I cannot continue loading more assets.

My idea was to attach to "onStateChange" signal and stop/pause the current async download, but there are no public methods in Phaser.Loader to do that.

Are there a good way to load assets asynchronously with state changes?

Thanks

Link to comment
Share on other sites

I had similar problem - and I basically ended up with creating second loader to do asynchronous stuff. This second loader is a modified code of original Phaser.Loader. But it is really ugly solution...

@rich I know that you don't recommend loading files async, but how you would do this when it is necessary (game needs to load fb avatars for multiplayer leader boards)?

Link to comment
Share on other sites

17 hours ago, rich said:

Why not just split it into 2 loads? One that loads the base essential files that your State needs, and another that then loads in the additional files, rather than trying to do it all at once?

Thanks for the reply Rich.

The main problem here it's the total game size (~100Mb). The game has a lot of animations, that are not "necesary" to show to play the game, but at some point, the animation will appear when has been loaded.

For example: We have 4 diferent scenes (A, B, C, D). Each scene has its own assets, which are loaded in its phase of preload. But each scene also has some assets that are not "necessary" (like heavy animations) that can be loaded throughout the entire life cycle of the game (in other process, not in a specific scene), while there are transitions between different scenes. The main goal is to play the game with the minimum necessary. The gameplay involves several transitions of playable scenes and while all this happens, we have to be able to download more assets asynchronously, to use them when they have downloaded (without being a priority for the execution of the game itself). Each scene that needs one of the "unnecessary" assets, checks if the asset is loaded into Phaser's cache and if it is available, it will use.

Attached is a picture with what is intended.

Am I focusing bad the problem? Could it be otherwise?

Thanks.

 

Boot State + Preload State.png

Link to comment
Share on other sites

  • 4 months later...
 Share

  • Recently Browsing   0 members

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