Challenge 2: Center-to-Center Measurement

Our measurements are not quite precise. We measure from the top left corner of a box containing the object. It is better to measure from the middle of the object, but it is also more complicated.

Use the anchorPointX and anchorPointY transform properties to record an offset to the middle of the objects. You will need to add these properties to the X and Y values of both objects when you are measuring distances.

It may help to draw some diagrams. Measure distances between corners and centers of different-sized boxes. Find out whether the distance is the same when using corners and centers.

results matching ""

    No results matching ""