diff --git a/arcade/sprite/animated.py b/arcade/sprite/animated.py index 0a88035f3f..c3fd7b5831 100644 --- a/arcade/sprite/animated.py +++ b/arcade/sprite/animated.py @@ -357,4 +357,4 @@ def update_animation(self, delta_time: float = 1 / 60) -> None: logger.warning("Error, no texture set") else: self.width = self._texture.width * self.scale_x - self.height = self._texture.height * self.scale_x + self.height = self._texture.height * self.scale_y diff --git a/tests/unit/sprite/test_sprite_animated_walking.py b/tests/unit/sprite/test_sprite_animated_walking.py index 46cf3ca92c..2d3f7df41c 100644 --- a/tests/unit/sprite/test_sprite_animated_walking.py +++ b/tests/unit/sprite/test_sprite_animated_walking.py @@ -5,6 +5,23 @@ frame_count = 0 +def test_update_animation_preserves_scale_y(): + # update_animation must size height from scale_y, not scale_x, so a + # non-uniform scale is preserved (regression: scale_y was clobbered). + texture = arcade.Texture.create_empty("test-scale", (10, 20)) + sprite = arcade.AnimatedWalkingSprite(scale=(2.0, 3.0)) + sprite.stand_right_textures = [texture] + sprite.texture = texture + sprite.change_x = 0 + sprite.change_y = 0 + + sprite.update_animation() + + assert tuple(sprite.scale) == (2.0, 3.0) + assert sprite.width == 20.0 + assert sprite.height == 60.0 + + def test_sprite_animated_old(window: arcade.Window): global frame_count frame_count = 0