var player ={ color:"#00A", x:220,
y:270,
width:32,
height:32,
draw:function(){
canvas.fillStyle=this.color;
canvas.fillRect(this.x,this.y,this.width,this.height); } };
我们现在用一个纯色的矩形来代表player.当我们把它加入游戏当中的时候,我们需要清除画布并且画上player.
function draw(){
canvas.clearRect(0,0, CANVAS_WIDTH, CANVAS_HEIGHT); player.draw();
}
更多相关产品资讯可以查询:html5游戏开发 http://subject.9ria.com/html5game.html