3
我有这样一段代码(该sCtx是画布背景和按钮是在紧张的平局循环):画布drawImage返回错误
function Button(src, onClick)
{
this.loaded = false;
this.image = new Image();
this.image.src = src;
this.onClick = onClick;
}
Button.prototype.draw = function()
{
if(!this.image.complete)
return;
var theImg = this.image;
console.log(theImg);
sCtx.drawImage(theImg);
}
当我运行的代码(在Chrome中)我得到这个输出:
<img src="img/btnStart.png">
Uncaught TypeError: Type error
有人能告诉我我做错了什么吗?我已经看了很多例子,看起来这应该起作用。
我有同样的问题。尽管添加了x,y坐标,但错误仍然存在。我该怎么做 – 2011-08-14 07:28:05