kineticjs - shift shapes in groupS -
i've got little problem. kinetic stage this:
stage -> layer0 -> group0 -> shapes layer1 -> group1 -> shapes layer2 -> group2 -> shapes
i need move group1 , group2 both when group0 event called (dragstart, dragmove etc). tried this:
group0.draggable = true; group0.on('dragstart', function(){ var = #save first mouse position point }) group0.on('dragmove', function(){ #ref group1 , group2 store in group0 , debugged in chrome, object recognize group1.setposition(my new positions x, y) group2.setposition(...) })
in other words. need connected groups different layers , treat them in 1 group nested 3 others groups. code doesnt work, bug or forgot something? how achieve this? there no error in console, doesnt work, can shift group0 group1 , group2 setposition function doesnt change despite seem call properly. thank you
i can speculate because don't have code in front of me.
but first thing check redrawing layers.
group0.on('dragmove', function(){ #ref group1 , group2 store in group0 , debugged in chrome, object recognize group1.setposition(my new positions x, y) group2.setposition(...) group1.getlayer().draw(); //redraw group1 layer group2.getlayer().draw(); //redraw group2 layer // stage.draw(); // possibility }) //you can transitions, redrawing you. group1.transitionto({ duration: 1, //how long animation takes in seconds x: new position x coord y: new position y coord }); //repeat other groups want moved
also, important note set position doesn't change position of items inside it, if had shape1 @ 100,100 still report being @ 100, 100 after group moved, since position relative container in.
Comments
Post a Comment