changed ball and bar for a sprite
This commit is contained in:
26
assets/js/Resources.js
Normal file
26
assets/js/Resources.js
Normal file
@ -0,0 +1,26 @@
|
||||
class Resources {
|
||||
constructor() {
|
||||
this.total = 0;
|
||||
this.loading = 0;
|
||||
this.resources = {};
|
||||
|
||||
this.load('ball');
|
||||
this.load('bar');
|
||||
}
|
||||
|
||||
|
||||
load(res) {
|
||||
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 + '.png';
|
||||
}
|
||||
|
||||
get(res) {
|
||||
return this.resources[res];
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user