[英]pygame how to rotate image properly?
In pygame I am unable to rotate an image/surface. 在pygame中,我无法旋转图像/表面。 The image is drawing properly just not rotating.
图像绘制正确,只是没有旋转。
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))
What exactly am I doing wrong? 我到底在做什么错?
1.- Which version are you using (both pygame and python)? 1.-您使用的是哪个版本(pygame和python)?
2.- You don't need radians 2.-您不需要弧度
3.- You must specify a problem your description seems ambiguous 3.-您必须指定一个问题,说明似乎模棱两可
Anyway I leave an example here. 无论如何,我在这里留下一个例子。 Good luck.
祝好运。
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.