<!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title></title> <script src="js/jquery-1.9.1.min.js"></script> <style> body{margin: 0; padding: 0;} </style> </head> <body> <canvas id="canvas"></canvas> </body> <script type="text/javascript"> var w=$(window).width(); var h=$(window).height(); var c=document.getElementById("canvas"); c.width=w; c.height=h-60; var ctx=c.getContext("2d"); var img=new Image(); var img1=new Image(); var hua=new Image(); img.src="img/yueliang.png"; img1.src="img/s1.png" hua.src="img/hua3.png" img.onload=function(){ ctx.drawImage(img,0,0,w,w/2.05) ctx.drawImage(img1,0,200,w,w/1.25) so(0,900) } function so(x,y){ ctx.drawImage(hua,x,y) } var x=0,y=0 setInterval(function(){ x+=5; y+=5; },100) </script></html>
1 回答
小白师兄
TA贡献55条经验 获得超37个赞
在你的定时器里面调用你的so(x,y)方法! 像这个样子
setInterval(function() { x += 5; y += 5; so( x, y) }, 100)
添加回答
举报
0/150
提交
取消