2
如何调整已经在画布中绘制的图像大小?html5画布图像调整大小
我想这没有运气(图片中展现,但它不调整):
var drawBall = function(mouseX, mouseY){
ballimg = new Image();
ballimg.onload = function(){
ctx.drawImage(ballimg, mouseX-25, mouseY-25);
ballimg.height = 5;
throwed = true;
};
ballimg.src = "ball2.png";
};
如何提高重绘速度? – dario111cro 2012-03-07 16:55:08
这取决于你想要的。如果你想重绘每一秒左右,你可以使用setInterval函数http://www.w3schools.com/jsref/met_win_setinterval.asp或者你可以手动触发重绘鼠标点击事件 – 1b0t 2012-03-07 17:13:32
也最好使用requestAnimationFrame比setInterval获得更好的性能。这里是由保罗爱尔兰人制作的polyfill ... http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/ – 2013-07-26 19:54:19