pygame如何正确旋转图像?

2024-10-04 01:34:19 发布

您现在位置:Python中文网/ 问答频道 /正文

在pygame中,我无法旋转图像/曲面。图像画得很好,只是没有旋转。

self.other1 = pygame.image.load("enemy.png").convert_alpha()
self.other2 = pygame.transform.rotate(self.other1, math.radians(270))
self.screen.blit(self.other2, (0, 0))

我到底做错了什么?


Tags: 图像imageselfalphaconvertpngtransformload
1条回答
网友
1楼 · 发布于 2024-10-04 01:34:19

1.-你在使用哪个版本(pygame和python)?

2.-你不需要弧度

3.-你必须说明一个你的描述模棱两可的问题

无论如何,我在这里留下一个例子。祝你好运。

import pygame
from pygame.locals import *

SIZE = 640, 480
pygame.init()
screen = pygame.display.set_mode(SIZE)

done = False
screen.fill((0, 0, 0))
other1 = pygame.image.load("enemy.png").convert_alpha()
other2 = pygame.transform.rotate(other1, 270)
screen.blit(other2, (0, 0))
pygame.display.flip()

while not done:
    for e in pygame.event.get():
        if e.type == QUIT or (e.type == KEYDOWN and e.key == K_ESCAPE):
            done = True
            break    

相关问题 更多 >