Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions arcade/sprite/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,12 +512,18 @@ def color(self, color: RGBOrA255):

@property
def alpha(self) -> int:
"""Get or set the alpha value of the sprite"""
"""
Get or set the alpha value of the sprite.

Will be clamped to the range 0-255.
"""
return self._color[3]

@alpha.setter
def alpha(self, alpha: int):
self._color = Color(self._color[0], self._color[1], self._color[2], int(alpha))
self._color = Color(
self._color[0], self._color[1], self._color[2], max(0, min(255, int(alpha)))
)

for sprite_list in self.sprite_lists:
sprite_list._update_color(self)
Expand Down
Loading