Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript HTML5画布DrawImage未指定错误_Javascript_Html_Internet Explorer_Html5 Canvas - Fatal编程技术网

Javascript HTML5画布DrawImage未指定错误

Javascript HTML5画布DrawImage未指定错误,javascript,html,internet-explorer,html5-canvas,Javascript,Html,Internet Explorer,Html5 Canvas,我正在使用canvas创建一个HTML5游戏。在IE中播放时,当运行以下代码时,我得到一个“SCRIPT16389:Unspecified error” ctx.drawImage( this.img, this.startX + (column*this.width), this.startY + (row*this.height), this.width, this.height, posX, posY, widt

我正在使用canvas创建一个HTML5游戏。在IE中播放时,当运行以下代码时,我得到一个“SCRIPT16389:Unspecified error”

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)

正在崩溃的精灵表大小为1174 KB。它是游戏中最大的文件。我也试着从游戏中移除那个精灵,但是游戏中的下一张图片也使它崩溃了。该图像的大小只有280 KB。

在调用此函数之前,请尝试
console.log()
每个参数,并将其发布到此处。此行中使用的this.width和this.height的区别是什么,然后是行尾的width和height值?您的图像已正确加载,方法为“onload”?这只发生在IE中吗?它在其他浏览器中工作吗?@code唯一:this.width和this.height是指精灵表对象上每个精灵的大小。宽度和高度是传入的参数,表示绘制图像的大小。