You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This module provides 3 functions loadImage, loadSound and loadJSON which can be used for loading images, sounds and json files asynchronously. They return a Promise which is resolved once the asset has been loaded, else rejects.
Loader
A Basic, Reusable Asset Loader
Example
constloader=newBottlecap.Loader();loader.on('load',onComplete);loader.on('error',onError);loader.addImage('spritesheet','./res/spritesheet.png').addSound('bgm','./res/bgm.mp3').addJSON('data','./res/data.json').load(,onError);constonLoad=loadedAssets=>{// pass loaded assets to asset manager};constonError=e=>{// handle error};// render functionrender(){if(loader.loading){drawLoadingScreen();return;}// do stuff}