Advertisement
EncryptedCow

Untitled

Oct 30th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export function assets(cb) {
  2.     const textureDir = "assets/textures/";
  3.     const textures = {
  4.         player: "player.png"
  5.     };
  6.  
  7.     const images = {
  8.         tiles: "tiles.png"
  9.     };
  10.  
  11.     const toLoad = Object.keys(textures).length + Object.keys(images).length;
  12.     let loaded = 0;
  13.  
  14.     for(let name in textures) {
  15.         Loader.loadTexture(name, textureDir + textures[name], loadObject);
  16.     }
  17.     for(let name in images) {
  18.         Loader.loadImage(name, textureDir + images[name], loadObject);
  19.     }
  20.  
  21.     function loadObject() {
  22.         loaded++;
  23.         console.log(`${loaded}/${toLoad} items loaded.`);
  24.         if(loaded === toLoad) {
  25.             cb();
  26.         }
  27.     }
  28.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement