Fix AnimatedWalkingSprite.update_animation clobbering scale_y - #2876
Open
uttam12331 wants to merge 1 commit into
Open
Fix AnimatedWalkingSprite.update_animation clobbering scale_y#2876uttam12331 wants to merge 1 commit into
uttam12331 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AnimatedWalkingSprite.update_animationsizes the sprite from the texture, but the height line usesscale_xinstead ofscale_y:The inherited
heightsetter derivesscale_yfrom the value assigned (self._scale = self._scale[0], value / self._texture.height), so assigningtexture.height * scale_xforcesscale_y := scale_x. Every animation update therefore both mis-sizes the sprite and silently corrupts a non-uniform scale.Repro (arcade 3.3.3):
Fix
Use
scale_yfor the height. Thewidthline one above already correctly usesscale_x, matching the base-class texture setters (sprite/base.py,sprite/sprite.py) which use_scale[0]for width and_scale[1]for height.Test
Added
test_update_animation_preserves_scale_yintests/unit/sprite/test_sprite_animated_walking.py— it constructs anAnimatedWalkingSprite(scale=(2.0, 3.0)), runsupdate_animation, and asserts the scale and dimensions are preserved. It fails ondevelopment(scale becomes(2.0, 2.0), height40.0) and passes with this change.ruff format --checkclean and the change adds no newruff checkfindings.AnimatedWalkingSpriteis soft-deprecated in its docstring, but it is still exported inarcade.__all__and is the sprite used in the platformer tutorial (platformer_part_twelve), so the silent scale corruption still affects users following the docs.