phamedev Posted September 29, 2017 Share Posted September 29, 2017 Is it possible to show the loading progress of a png sptire atlas and its json file? Something like we used to do in flash with totalBytes and loadedBytes? Link to comment Share on other sites More sharing options...
Cudabear Posted September 29, 2017 Share Posted September 29, 2017 As far as I know, this isn't really feasible because there's no way to know how big the file being downloaded is. It's possible to get the `header` information from the request to get the total number of bytes downloaded already, and then compare that to some hard-coded value about the size of the value (or fetch the size of the file via some back-end request) but that seems fragile and too heavy-handed. Most Phaser games show progress as a percent of total files downloaded (not great if you've got a big sprite atlas, or large music files, but it's something at least) Here's my example of how I show progress of loaded files:https://github.com/Cudabear/ldwrap/blob/master/src/state/LoadState.js The important line is `this.load.setPreloadSprite`. Link to comment Share on other sites More sharing options...
phamedev Posted September 29, 2017 Author Share Posted September 29, 2017 Thanks Cudabear. i can use the total number of bytes downloaded as I already know the total size of the atlas. Can that information (bytes downloaded) be obtained from Loader or other Phaser object? Link to comment Share on other sites More sharing options...
samme Posted September 30, 2017 Share Posted September 30, 2017 Using XMLHttpRequest: Monitoring progress Link to comment Share on other sites More sharing options...
Recommended Posts