Skip to content

Allow tuple scale in arcade.Sprite init, same as the setter #2399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bunny-therapist opened this issue Oct 8, 2024 · 1 comment · Fixed by #2389
Closed

Allow tuple scale in arcade.Sprite init, same as the setter #2399

bunny-therapist opened this issue Oct 8, 2024 · 1 comment · Fixed by #2389
Milestone

Comments

@bunny-therapist
Copy link

Enhancement request:

What should be added/changed?

The scale argument to arcade.Sprite.__init__ is a float (https://github.com/pythonarcade/arcade/blob/development/arcade/sprite/sprite.py#L73) but the getter for the scale property returns a tuple and the setter for it accepts both tuple and float (https://github.com/pythonarcade/arcade/blob/development/arcade/sprite/base.py#L310).

I would like the scale argument to __init__ to work the same way as the property setter, so it accepts both a 2-tuple and a float.

What would it help with?

I can easily pass the scale of one sprite to the init of a new sprite, same as I could in older versions of arcade (before the scale getter started to return a tuple).

@einarf
Copy link
Member

einarf commented Oct 8, 2024

It should accept both. There is a PR about to be merged that also adds performant methods to do uniform scaling and other scaling cleanup. The new scale property that was initially added returns a Vec2, but this was such a huge impact on performance (4-5x more costly) we had to find another way.

I will put this on 3.0 mandatory in case this change was not added in the subclass.

@einarf einarf added this to the 3.0 mandatory milestone Oct 8, 2024
@DragonMoffon DragonMoffon linked a pull request Oct 14, 2024 that will close this issue
DragonMoffon added a commit that referenced this issue Oct 14, 2024
* Update scale `__init__` argument, and delete floating simple.py file

* Adding correct typing to Sprite and AnimatedSprite for scale, and adding validation unit tests

* Sprite now makes input scale a 2 length tuple rather than arbitrary in length

* removing sprite.simple from quick index generation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants