[英]pygame copy image, then rotate it
我有一張我想在屏幕上多次使用的圖片,但它總是必須以不同的方式旋轉。 如果我使用 pygame.image.rotate function 它會旋轉導入的圖像,因此我無法單獨旋轉每個圖像。 有什么辦法可以在代碼中復制它然后旋轉它?
> image = pygame.image.load("assets/image")
pygame.transform.rotate(image, 20) #rotated by 20 deg
pygame.transform.rotate(image, 20) #rotated by 20 + 20 deg
#what i want
copy(pygame.transform.rotate(image, 20))
如果您使用pygame.image.load()
並將其放入變量中,然后再次放入另一個變量中
例如:
image = pygame.image.load(path) #if you load like that
image_2 = pygame.image.load(path)
image = pygame.transform.rotozoom(image,90,1) #image 2 stays the same and you can rotate it a different way
function pygame.image.rotate
不存在,但pygame.transform.rotate
確實存在。
pygame.transform.rotate
不會旋轉圖像本身。 此 function 創建圖像的旋轉副本並返回副本:
image = pygame.image.load("assets/image")
rotated_image_copy = pygame.transform.rotate(image, 20)
另請參閱如何使用 PyGame 圍繞其中心旋轉圖像? .
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.