From 3d267fd48e0c688c462410364e9db92087e8a4f0 Mon Sep 17 00:00:00 2001 From: uttam12331 Date: Mon, 27 Jul 2026 09:57:11 +0530 Subject: [PATCH] Fix AnimatedWalkingSprite.update_animation clobbering scale_y update_animation set height from scale_x instead of scale_y: self.height = self._texture.height * self.scale_x The height setter derives scale_y from the assigned value, so this forced scale_y := scale_x on every animation update -- mis-sizing the sprite and silently corrupting a non-uniform scale (e.g. scale (2, 3) became (2, 2)). The width line one above already uses scale_x, matching the base-class setters which use _scale[0] for width and _scale[1] for height. Use scale_y. --- arcade/sprite/animated.py | 2 +- .../unit/sprite/test_sprite_animated_walking.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) 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