我可以将javascript绘图功能更改为图像吗?

时间:2015-03-24 13:42:32

标签: javascript png draw

我今天在github上发现了一个游戏代码[https://github.com/maryrosecook/retro-games]。我想编辑它并使用png图像而不是绘图功能,无论如何我能做到吗? 谢谢。

  BodyBlock.prototype = {
    draw: function(screen) {
      drawRect(screen, this, "black");
    }

1 个答案:

答案 0 :(得分:1)

drawRect()是自定义的,从头开始的功能。

var drawRect = function(screen, body, color) {
  screen.fillStyle = color;
  screen.fillRect();
};

您正在寻找的是标准的javascript canvas方法。 http://www.w3schools.com/tags/canvas_fillrect.asp

教程:http://www.html5canvastutorials.com/tutorials/html5-canvas-lines/

相关问题