Sets PositionComponent#setByRect to also use anchor property. Change in #99 was a breaking change for setByRect when using the results of toRect as they now used different anchors which would cause the set rect to translate to a new incorrect position.

This commit is contained in:
Illia Poplawski
2019-06-01 07:32:22 -04:00
parent 63115cf7b9
commit 0ce355b891

View File

@ -79,8 +79,8 @@ abstract class PositionComponent extends Component {
Rect toRect() => Rect.fromLTWH(x - anchor.relativePosition.dx * width,
y - anchor.relativePosition.dy * height, width, height);
void setByRect(Rect rect) {
x = rect.left;
y = rect.top;
x = rect.left + anchor.relativePosition.dx * rect.width;
y = rect.top + anchor.relativePosition.dy * rect.height;
width = rect.width;
height = rect.height;
}