I did a mini game on localhost and everything was working perfectly .. Then I uploaded it to the web server and the game started to crash with the error "NS_ERROR_NOT_AVAILABLE:".
...
var spriteSheet = new Image();
var player = new Sprite(spriteSheet);sprites.push(player);
...
for (var i in sprites) {
var spr = sprites[i];
if (spr.visible) {
spr.draw(ctx); // erro aqui
}
}
...
(in another .js file)
...
this.draw = function(ctx){
ctx.drawImage(this.img, this.srcX, this.srcY, this.width, this.height,this.posX,this.posY, this.width, this.height); // erro aqui
this.animation();
}
...
I've been looking into this and I think you need to create a function to load the images before starting the game itself.