役に立ちましたか?

解決

新しい行を作成して、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/

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top