melonJS icon indicating copy to clipboard operation
melonJS copied to clipboard

[Feature request] More realistic progress based on bytes for loader and preloader

Open cuixiping opened this issue 2 years ago • 0 comments

I wish there is a more realistic progress handler based on bytes.

Example code:

let assets = [
     { name : 'image1', src : 'images/image1.png', bytes: 120366 },  // 6.4%
     { name : 'image2', src : 'images/image2.png', bytes: 170214 },  // 9.0%
     { name : 'image3', src : 'images/image3.png', bytes: 192252 },  // 10.2%
     { name : 'binary', src : 'data/binary-data-001', bytes: 1401286 }  // 74.4%
];
let updateProgressDisplay = percent => {
  // do something
};
me.loader.preload(assets,  {
    completed: ()=>this.loaded(),
    progress: (e) => updateProgressDisplay(e.percent)),
});

But it's not a good way if input the bytes numbers manually.

It will be better if some build scripts generate those numbers automatically.

What do you think about it?

.

cuixiping avatar Jul 06 '23 12:07 cuixiping