class Resources { constructor() { this.total = 0; this.loading = 0; this.resources = {}; this.load('bg01', 'jpg'); this.load('ball'); this.load('bar'); this.load('b31'); this.load('b32'); this.load('b33'); } load(res, ext='png') { let _this = this; this.total++; this.loading++; this.resources[res] = new Image(); this.resources[res].onload = function () { _this.loading--; } this.resources[res].src = 'assets/imgs/' + res + '.'+ext; } get(res) { return this.resources[res]; } };