Altered the move_sprite_to method to correctly move a sprite which ha…#59
Altered the move_sprite_to method to correctly move a sprite which ha…#59WhyPenguins merged 1 commit intothoth-tech:t2-2024from
Conversation
…s its position_at_anchor point set to true
Wills2022
left a comment
There was a problem hiding this comment.
Tested change in code, does not generate any errors, does not break unit tests and test code (specifically i tested "cave escape", sprite test & shape drawing. This does not appear to break the way that sprite rotation works in existing games, at least as far as test cases are concerned. It might cause some unusual behavior in user code if users have noticed this behavior and tried to correct it themselves. I do not believe that this is something we can realistically test for however.
Going forwards please feel free to modify the test code for the relevant class(es) if you modify them. I believe you mentioned writing tests during the standup, so please feel free to integrate them into the pull. Otherwise please include a (brief) description of your testing methodology in the pull.
|
I agree that this logic makes a lot more sense. If you set the anchor position for a sprite then it's reasonable to expect that when moving the sprite it would be relative to the anchor position. As Will mentioned, this will probably break some existing code however I believe it's better to update the broken code rather then have an unintuitive api design. I'll bring up with the leadership team to make sure that they are aware of the potential for existing projects to break. Thanks for the PR, LTGM! |
WhyPenguins
left a comment
There was a problem hiding this comment.
Nice work! This logic definitely makes more sense, looks good to merge😄
|
Also just as a note in case it's useful for anyone looking at this area in the future, The function to enable/disable this ( |
The move_sprite_to method produces incorrect behavior when a sprite has the Boolean field position_at_anchor_point set to true.
For example, take a 10x10 sprite which is positioned at world coordinates {10,10}. Its anchor is then {5,5} in sprite coordinates and {15,15} in world coordinates. Now when move_sprite_to(sprite, 20.0, 20.0) is called the sprite’s updated position is {25,25} with an anchor position of {30,30}.
With my alteration to the method, the sprite position would be {15,15} with an anchor position of {20,20}. This seems more natural as the sprite’s position is now being set by its anchor position, as intended by the position_at_anchor_point Boolean being true.