2012-11-08 71 views
2

默認情況下,Kineticjsv4.0.5不支持圖像的邊框,因此.showBorder().hideBorder()會導致錯誤說如何顯示在周圍kineticjs V4.0.5圖像的邊框

Uncaught TypeError: Object # has no method 'showBorder'

但是當我包括圖片插件v1.0.1 JavaScript文件,我的遊戲根本沒有出現,而FireBug根本沒有報告錯誤。

我還在github上啓動了issue

問候,

回答

3

試試這個代碼

<!DOCTYPE HTML> 
<html> 
    <head> 
    <script src="http://www.html5canvastutorials.com/libraries/kinetic-v4.0.5.js"></script> 

    <script> 
     window.onload = function() { 
     var stage = new Kinetic.Stage({ 
      container: "container", 
      width: 578, 
      height: 200 
     }); 
     var layer = new Kinetic.Layer(); 

     var imageObj = new Image(); 
     imageObj.onload = function() { 
      var yoda = new Kinetic.Image({ 
      x: 140, 
      y: stage.getHeight()/2 - 59, 
      image: imageObj, 
      width: 106, 
      height: 118, 
      stroke:"Red", 
      strokeWidth:5 
      }); 

      // add the shape to the layer 
      layer.add(yoda);   

      // add the layer to the stage 
      stage.add(layer); 
      yoda.on('mouseover', function() { 
       yoda.setStrokeWidth("Transparent"); 
       yoda.setStroke(0); 
       layer.draw(); 
      }); 
     }; 
     imageObj.src = "http://www.html5canvastutorials.com/demos/assets/yoda.jpg"; 
     };  
    </script> 
    </head> 
    <body> 
    <div id="container"></div> 
    </body> 
</html> 
+0

是啊,這就是我所做的。謝謝。我會接受你的回答。 –

相關問題