2012-10-02 62 views

回答

4

您可以创建一个新行并将其添加到mousedown上的图层。

 stage.on("mousedown", function(){ 
      if (moving){ 
       moving = false;layer.draw(); 
      } else { 
       var mousePos = stage.getMousePosition(); 
       //CHANGED - Create new line 
       line = new Kinetic.Line({ 
        points: [0, 0, 50, 50], 
        stroke: "red" 
       }); 
       //CHANGED - Add line to layer 
       layer.add(line); 
       //start point and end point are the same 
       line.getPoints()[0].x = mousePos.x; 
       line.getPoints()[0].y = mousePos.y; 
       line.getPoints()[1].x = mousePos.x; 
       line.getPoints()[1].y = mousePos.y; 

       moving = true;  
       layer.drawScene();    
      } 

     }); 

检查演示:http://jsfiddle.net/QTsgn/

+0

这正是我需要的,对不起,我是新蒂奥kineticsjs :) – Mike