tzachshabtay / MonoAGS

AGS (Adventure Game Studio) reimagined in Mono
https://tzachshabtay.github.io/MonoAGS/
Artistic License 2.0
27 stars 8 forks source link

Anchor to Parent #245

Open ghost opened 6 years ago

ghost commented 6 years ago

Not sure if this is by design, but parent's pivot does not seem to have an effect on children's placement.

For example:

Setting child's coordinates to (2, -2 + PH) positions it where wanted (at parent, with 2,-2 offset).

tzachshabtay commented 6 years ago

So I thought about it a little bit, and I'm not sure what the correct behavior here should be.

As a counter example, take a look at the inventory panel in the demo game: I'm placing it at the center of the screen with the pivot as (0.5, 0.5) as an easy way to have it centered. But for the button panel on the left, it still makes sense to place it at x = 5 and not x = 5 - PW/2.

Also, if I want to rotate said panel, one time around the center, and one time around the top-left point, it makes sense to only change its pivot and position without needing to also change the positions of all of the children.

For what you want, I think maybe we need an additional feature for specifying anchoring.

As a side note, to make the behavior you want, all it takes is to pass null instead of the parent's pivot in the matrix component (https://github.com/tzachshabtay/MonoAGS/blob/2f85d1847ae8e8cab83b53229f6dd8bc347e0cc2/Source/Engine/AGS.Engine/Objects/AGSModelMatrixComponent.cs#L338), so from the perspective of the code, it will actually change it to "ignore" the parent's pivot, i.e the opposite of the title.

ghost commented 6 years ago

For what you want, I think maybe we need an additional feature for specifying anchoring.

Yes, I guess that's what is missing. Since pivot is like a private property that defines the image positioning.