HTML5 Canvas DrawImage未指定错误

时间:2015-07-29 02:50:51

标签: javascript html5 internet-explorer html5-canvas

我正在使用画布创建HTML5游戏。在IE中播放时,我在运行以下代码时收到“SCRIPT16389:未指定的错误”。

ctx.drawImage(
    this.img, 
    this.startX + (column*this.width), 
    this.startY + (row*this.height), 
    this.width, 
    this.height, 
    posX, 
    posY, 
    width, 
    height
);

此错误发生在游戏结束时使用相同的图像。在整个游戏中还有其他图像使用完全相同的代码,但它们没有得到错误。有关可能导致此错误的原因的任何建议?

更新

这只发生在IE中。它在Chrome和Firefox中运行良好。

这是变量崩溃时的console.log。

this.img.complete :true
this.startX :0
column :0
this.startX + (column*this.width) :00
this.startY :0
row :0
this.startY + (row*this.height) :00
this.width :1200
this.height :1200
posX :204
posY :68
width :612
height :612

图像被添加到名为Game.sprites的对象中。它们按以下方式添加

var imageObj = new Image();
imageObj.src = assetDir + "Images/myImage.png";
Game.sprites.myImageAnimation = new AnimatedSpriteSheet(imageObj, 0, 0, 1200, 1200, 5, 24);
//function AnimatedSpriteSheet(img, startX, startY, width, height, imagesPerRow, imageCount)

崩溃的spritesheet大小为1,174 KB。它是游戏中最大的文件。我也尝试从游戏中移除那个精灵,但是游戏中的下一个图像也崩溃了。该图像的大小仅为280 KB。

0 个答案:

没有答案
相关问题