在KineticJS中,我试图在onclick函数上旋转一条线。
var stage= new Kinetic.Stage({
container: 'container',
width: 500,
height: 500
});
var layer= new Kinetic.Layer();
var redLine = new Kinetic.Line({
points: [73, 70, 340, 23],
stroke: 'red',
strokeWidth: 15,
draggable: true
});
redLine.setOffsetX(73) //its showing offset not a function
redLine.setOffsetY(70)
redLine.setAttrs({x:73,y:70});
layer.add(redLine);
layer.draw();
var angle=0;
redLine.on('click',function(){
angle=angle+0.1
redLine.rotate(angle);
layer.draw();
});
stage.add(layer);
答案 0 :(得分:0)