图形BitMapFill TypeError

时间:2013-06-20 19:11:10

标签: javascript jquery graphics bitmap easeljs

我正在使用easeljs javascript制作一种游戏。 我正在使用这个例子:http://www.createjs.com/#!/EaselJS/demos/game

正如你所看到的那样有间隔弹。这是图形对象:

this.graphics.beginStroke("#FFFFFF");

我想用这样的图像填充背景:

var bitmap = new createjs.Bitmap("http://nielsvroman.be/twitter/root/easeljs/image.png");
this.graphics.beginBitmapFill(bitmap, "no-repeat"); 

但我总是得到这个错误:

  

未捕获的TypeError:输入错误

enter image description here

有人知道我做错了吗?

1 个答案:

答案 0 :(得分:2)

使用对HTML图像的引用,而不是Bitmap实例。

var image = new Image();
image.srce = "http://nielsvroman.be/twitter/root/easeljs/image.png";
this.graphics.beginBitmapFill(image, "no-repeat"); 

请注意,您必须确保已加载图像,否则它可能不会显示在第一阶段更新中。您可以勾选舞台,也可以听取图像上传,然后刷新舞台。

image.onload = function() {
    stage.update();
}
相关问题