gurkenlabs / litiengine

LITIENGINE 🕹 The pure 2D java game engine.
https://litiengine.com/
MIT License
725 stars 93 forks source link

GuiComponent.setX() and .setY() adjust child component positions twice #475

Closed Hades948 closed 1 year ago

Hades948 commented 1 year ago

Describe the bug GuiComponent.setX() and .setY() make a call to setLocation(). setLocation() adjusts the location of the children components based on the delta. But then setX() and setY() also adjust the respective values for the children components.

To Reproduce Steps to reproduce the behavior:

  1. Create a GuiComponent with a child GuiComponent.
  2. Call setX or setY on the parent component
  3. The child component is in the wrong position.

Expected behavior Only adjust the children components in one spot. Probably just remove the code in setX and setY that does it and let setLocation handle it.

Your System:

Additional context A work-around could be only using setLocation. But the tweening framework uses only setX and setY, even with TweenType.POSITION_XY. On that same note, it might make more sense to use setLocation for TweenType.POSITION_XY. Regardless, you should be able to get past this, too, if you overwrite setTweenValues in the GuiComponent to use setLocation instead.

nightm4re94 commented 1 year ago

This has been resolved by https://github.com/gurkenlabs/litiengine/commit/506cfee6fabd75fef25d77b28deaee163feaea6b. guicomponent_location