ETo*_*reo 3 javascript html5 canvas
我有这段代码(sCtx是一个画布上下文,按钮处于紧密的绘制循环中):
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);
}
Run Code Online (Sandbox Code Playgroud)
当我运行代码(在Chrome中)时,我得到了这个输出:
<img src ="img/btnStart.png">
未捕获的TypeError:输入错误
有人能告诉我我做错了什么吗?我看了很多例子,看起来这应该有效.
小智 5
我相信你需要x/y坐标才能告诉画布上下文绘制的位置:
sCtx.drawImage(theImg,0,0);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3298 次 |
| 最近记录: |