2013-06-20 59 views
0

我想說明的形狀像這樣的例子:http://www.createjs.com/#!/EaselJS/demos/game圖形beginBitmapFill easeljs

我想加載圖像填充形狀。 這是我做的:

var img = "<img src='http://nielsvroman.be/twitter/root/easeljs/image.png'>"; 

//setup 
this.graphics.clear(); 
this.graphics.beginStroke("#FFFFFF"); 
this.graphics.beginBitmapFill(img); 
this.graphics.moveTo(0, size); 

但我不斷收到此錯誤:

Uncaught TypeError: Type error

在Graphic.js創建此錯誤: enter image description here

文件:http://nielsvroman.be/twitter/root/game.html

回答

2

這很明顯,你傳遞一個字符串,而不是一個圖像(HTMLImageElement)。

嘗試:

var img1 = new Image(); 
img1.src = 'image1.png'; 

var img1 = document.createElement('img') 
img2.src = 'image2.jpg';