mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Loading of levels is working now
This commit is contained in:
@@ -10,6 +10,12 @@ export default class ImageLoader
|
||||
if (this.numberImagesLoaded === this.images.length) {
|
||||
window.dispatchEvent(new Event('imagesloaded'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
isComplete()
|
||||
{
|
||||
return this.numberImagesLoaded === this.images.length;
|
||||
}
|
||||
|
||||
getCurrentProgress()
|
||||
@@ -19,14 +25,19 @@ export default class ImageLoader
|
||||
|
||||
addImage(imagePath)
|
||||
{
|
||||
let image = new Image();
|
||||
image.src = imagePath;
|
||||
image.addEventListener(
|
||||
'load', () => {
|
||||
this.update();
|
||||
}
|
||||
);
|
||||
|
||||
this.images.push(image);
|
||||
this.images.push(imagePath);
|
||||
}
|
||||
}
|
||||
|
||||
load()
|
||||
{
|
||||
for (const imagePath of this.images) {
|
||||
let image = new Image();
|
||||
image.src = imagePath;
|
||||
image.addEventListener(
|
||||
'load', () => {
|
||||
this.update();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user