Canvas - 移动图像问题 [英] Canvas - move image-problem
本文介绍了Canvas - 移动图像问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个问题,我的脚本使用画布。
我想移动我的图像,但drawImage图像移动,但结果是这样: / p>
>
所以,我的代码是
function desenhaBonecoDir(){
var ctxt = document.getElementById('camadaBoneco')。getContext(2d);
bonecoX = bonecoX -10;
ctxt.drawImage(bonecoLeft,bonecoX,bonecoY);
}
我认为唯一的办法是使用SVG模式)。它是正确的?
任何教程?或示例? - 如何使用SVG移动图像
我如何解决这个问题?
感谢
解决方案
这段代码解决了我的问题
context2D.clearRect(0,0,canvas.width ,canvas.height);
这里很好的例子: http://brighthub.com/internet/web-development/articles/38744.aspx?p=3
i have a problem with my script that use canvas.
I want to move my image but with drawImage the image moves but the result is something like that:
so, my code is
function desenhaBonecoDir(){
var ctxt = document.getElementById('camadaBoneco').getContext("2d");
bonecoX = bonecoX -10;
ctxt.drawImage(bonecoLeft, bonecoX, bonecoY);
}
and i think that the only way is using SVG (retained mode). It is correct?
Any tutorial? or example? - "how moving an image with SVG" How i can solve that?
Thanks
解决方案
This code solves my problem
context2D.clearRect(0, 0, canvas.width, canvas.height);
Good example here: http://brighthub.com/internet/web-development/articles/38744.aspx?p=3
这篇关于Canvas - 移动图像问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文