我在这一层有一个可拖动的图层和一个大的透明背景。我想在用户点击的位置准确添加文本。当我没有拖动图层时,一切正常,但是当我拖动它时,文本将添加到我不想要的地方。因为event.x和event.y不是点击区域的形状的x和y。坐标必须转换。但我不知道如何获得转换矢量。如何获取点击形状的位置(KineticJS)
plot = {};
plot.stage = new Kinetic.Stage({width: 500, height:500,
container: 'abc',
'draggable': true});
plot.layer = new Kinetic.Layer();
plot.stage.add(plot.layer);
plot.background = new Kinetic.Rect({
x: -1000,
y: -1000,
width: 2000,
height: 2000,
fill: "#000000",
opacity: 0.05,
type: 'blank'
});
plot.layer.add(plot.background);
plot.background.on('click', function(e) {
e.x;
e.y;
// e.x and e.y are not true after dragging stage
});
这是可能的,但不知道你做了什么。代码plz – allenhwkim 2013-02-28 14:55:59