Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export function assets(cb) {
- const textureDir = "assets/textures/";
- const textures = {
- player: "player.png"
- };
- const images = {
- tiles: "tiles.png"
- };
- const toLoad = Object.keys(textures).length + Object.keys(images).length;
- let loaded = 0;
- for(let name in textures) {
- Loader.loadTexture(name, textureDir + textures[name], loadObject);
- }
- for(let name in images) {
- Loader.loadImage(name, textureDir + images[name], loadObject);
- }
- function loadObject() {
- loaded++;
- console.log(`${loaded}/${toLoad} items loaded.`);
- if(loaded === toLoad) {
- cb();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement