Copy link to clipboard
Copied
I have a stage 560x410. All of my movie clips are placed on the stage directly so are all in the same container.
Now, movieClip1 is clearly visible on the stage and I am trying to draw a line from this movieclip to another.
Here is my code:
draw_line(
_.holderExample, _.movieClip1.x, _.movieClip1.y,
_.movieClip2.x, _.movieClip3.y,
"#0000CC", 1);
function draw_line(
holder, startX, startY,
endX, endY,
colour, stroke)
{
holder.removeAllChildren();
let drawing_obj = new createjs.Shape();
holder.addChild(drawing_obj);
drawing_obj.graphics.setStrokeStyle(stroke).beginStroke(colour);
drawing_obj.graphics.moveTo(startX, startY);
drawing_obj.graphics.lineTo(endX, endY);
};
It is clearly saying 'Start drawing from the x and y position of movieClip1' but for some reason, it is all skewed to the right massively. Please see the image below. The arrowhead labelled 'A' is movieClip1 and the black lines marking the center axes are movieClip2 and movieClip3 respectively.
**IMAGE REMOVED DUE TO BEING COPYRIGHTED WORK. MASSIVE APOLOGIES**
It's extra frustrating because:
a) the 'A' label is being placed with the same x coordinate plus a couple of pixels no issue.
b) the line seems perfect length etc, just not in the right place.
Please help!
All coordinates in Animate are relative to each container's local frame of reference. If you want your container clip's coordinate system to coincide with its parent, you must position it so it does, and don't scale it. Try drawing a rect the same dimensions as your stage to check alignment.
Copy link to clipboard
Copied
All coordinates in Animate are relative to each container's local frame of reference. If you want your container clip's coordinate system to coincide with its parent, you must position it so it does, and don't scale it. Try drawing a rect the same dimensions as your stage to check alignment.
Copy link to clipboard
Copied
EDIT: All sorted. I set the holders to 0,0. Thank you again!
Thanks for replying again Clay! You seem to run this place on your own haha.
Could you possibly elaborate or point me to some documentation explaining the following:
"All coordinates in Animate are relative to each container's local frame of reference"
Thanks again!
Copy link to clipboard
Copied
I don't understand what you believe remains to be explained.