我一直试图在使用中围绕其中心旋转图像,pygame.transform.rotate()但它不起作用。特别是挂起的部分是rot_image = rot_image.subsurface(rot_rect).copy()。我得到了例外:
ValueError: subsurface rectangle outside surface area
以下是用于旋转图像的代码:
def rot_center(image, angle):
"""rotate an image while keeping its center and size"""
orig_rect = image.get_rect()
rot_image = pygame.transform.rotate(image, angle)
rot_rect = orig_rect.copy()
rot_rect.center = rot_image.get_rect().center
rot_image = rot_image.subsurface(rot_rect).copy()
return rot_image
慕姐8265434
相关分类