Jump to content

correct way of loading assets


feri
 Share

Recommended Posts

Hi All

I was using Phaser 2.4.4 to develop my game framework(intention is to use it as base for multiple games) and it worked perfectly on 2.4.4 but when I upgraded to 2.4.6 it failed to load sounds, atlas, bitmap font ,...

I looked at the phase code and the issue is in "finishedLoading" function where in new version the order of calling "this.reset()" and "this.game.state.loadComplete()" are changed.

I am sure it is not Phaser bug and I did something silly in my code but not sure what. basically I have my own json file where I declared all assets need to be loaded (my own version of asset pack json) and I load it in prelaod, then in create function, I go through the json and start adding assets to phase queue by calling "this.load.audiosprite", "this.load.atlas", ... and then I start loading. I also added 3 events in my create function to listen to loading events

 this.load.onLoadStart.add(this.loadStart, this);
 this.load.onFileComplete.add(this.fileComplete, this);
 this.load.onLoadComplete.add(this.loadComplete, this);

But it fails to load my assets and aborts loading and throws "Phaser.Loader - active loading canceled / reset".

Just want to know what is the right way to load assets? I know I can load my assets in preload and not in create but I need my asset pack json to be loaded so I know what assets need to be loaded later , as I said, this meant to be used for multiple games and each game will have its own assets, so its impossible to load them in prealod before my asset pack json is loaded. the other solution is to use Phaser asset pack which requires some work from me which I would prefer to find a solution for my current implementation if possible before I redo the loading logic in my code

sorry about long description and thanks for your help in advance

 

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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