2012-07-28 18 views
0

我正在使用Kinetic.JS庫開發HTML5應用程序。 我使用Kinetic.Image加載圖像(格式爲.PNG),並使用像素檢測僅檢測圖像的非透明部分。問題是我無法正確拖動我的圖像,雖然我已將draggable屬性設置爲true並使用saveImageData方法。 圖像被拖動之前(使用path檢測)。任何解決方案傢伙 這是我的代碼:Kinetic.JS圖像使用像素檢測後無法拖動

var beeObj = new Image(); 
     beeObj.onload = function(){ 
      bee = new Kinetic.Image({ //bee is global variable 
      x: 325 - 45, 
      y: 145 - 83, 
      image: beeObj,   
      draggable: true   
     }); 
     lineLayer.add(bee); 
     lineLayer.draw(); 
     bee.saveImageData(); 
    }; 
    beeObj.src = directory + "smile_bee.png"; 
+0

NB:Kinetic.JS版本:動能v3.10.4.js – 2012-07-28 17:59:03

回答

0

還有就是你的圖像加載器內沒有DetectionType .. 它應該像

bee = new Kinetic.Image({ //bee is global variable 
     x: 325 - 45, 
     y: 145 - 83, 
     image: beeObj,   
     draggable: true, 
     DetectionType: 'Pixels'   
    }); 

和鼠標了,你可以使用相同的功能,即

bee.saveImageData();

,並結束與相同功能 整個的onload函數,那麼它會工作

現在埃裏克具有剝離V4 + 所以現在沒有像素檢測型

,你可以使用類似

image.createImageBuffer(); 

//清晰圖像緩衝器

 image.clearImageBuffer(); 

希望這HELS ..

問候