Reputation: 4346
I want to make few shapes draggable/scalable/rotatable synchronized by one command. Is there a build-in function to link them or make them nested? Or should I just put them in an array and iterate my command on each of them?
Upvotes: 0
Views: 91
Reputation: 11294
You can add any number of display objects to a container, and do transformation operations on the container instead.
var shape = new createjs.Shape();
shape.graphics.f("#f00").dc(0,0,25);
var shape2 = new createjs.Shape();
shape2.graphics.f("#00f").dc(0,0,25);
shape2.x = 100;
var container = new createjs.Container();
container.addChild(shape, shape2);
stage.addChild(container);
container.x = container.y = 100;
container.rotation = 45;
// Move the container on the x-axis when dragged
container.on("pressmove", function(e) {
container.x = stage.mouseX;
});
Here is a fiddle: http://jsfiddle.net/2m9yff9x/
Upvotes: 2