-
Notifications
You must be signed in to change notification settings - Fork 363
Closed
Description
Bug Report
Changing Sprite.width/height does not update hitbox.
This results in wrong behaviour using:
Sprite.left/right/top/bottomSprite.collides_with_point- GUI Button clicks
Actual behavior:
Running example code fails with AssertionError
Expected behavior:
Changing properties of sprite like Sprite.width/height should update the hitbox.
Example code draws Sprite, passing the asserts
Steps to reproduce/example code:
import arcade
from arcade import Window, Sprite, get_window
class MyWindow(Window):
def __init__(self):
super().__init__()
arcade.set_background_color((0, 0, 0))
self.sprite = Sprite(":resources:images/space_shooter/playerShip1_orange.png")
self.sprite.position = get_window().width / 2, get_window().height / 2,
# Sprite width before : 90
print(self.sprite.width)
# Double sprite width: 180
self.sprite.width = 180
print(self.sprite.width)
hit = self.sprite.collides_with_point((self.sprite.center_x + 80, self.sprite.center_y))
assert hit
assert self.sprite.right == self.sprite.center_x + 90
def on_draw(self):
arcade.start_render()
self.sprite.draw()
if __name__ == '__main__':
window = MyWindow()
arcade.run()
Metadata
Metadata
Assignees
Labels
No labels