我有两组对称显示,在舞台上,每一组都包含一条线,我的要求是当我移动一组时,另一组对称地移动到第一组。
这是代码
stage = new Kinetic.Stage({
container: 'container',
width: 900,
height: 450
});
mouse = stage.getMousePosition();
layer = new Kinetic.Layer();
stage.on("mousedown", function () {
traitGroup = new Kinetic.Group({
x: mouse.x,
y: mouse.y,
draggable: true
});
traitGroupMir = new Kinetic.Group({
x: stage.getWidth()-mouse.x,
y: mouse.y,
draggable:true
});
layer.add(traitGroup);
layer.add(traitGroupMir);
line = new Kinetic.Line({
points: [0, 0, 0, 0],
stroke: "red",
strokeWidth: 5,
draggable: false
});
lineMirr = new Kinetic.Line({
points: [0, 0, 0, 0],
stroke: "red",
strokeWidth: 5,
draggable: false
});
traitGroup.add(line);
traitGroupMir.add(lineMirr);
traitGroup.on('dragstart', function() {
this.moveToTop();
});
traitGroupMir.on('dragstart', function() {
this.moveToTop();
});
traitGroup.on('dragmove', function() {
traitGroupMir.setX(stage.getWidth()-this.getX());
traitGroupMir.setY(this.getY());
});
traitGroupMir.on('dragmove', function() {
traitGroup.setX(stage.getWidth()-this.getX());
traitGroup.setY(this.getY());
});
stage.add(layer);
});
代码中是否有错误?