小编Dee*_*wal的帖子

如何设置pygame.transform.rotate()的轴心点(旋转中心)?

我想围绕中心以外的点旋转矩形.到目前为止我的代码是:

import pygame

pygame.init()
w = 640
h = 480
degree = 45
screen = pygame.display.set_mode((w, h))

surf = pygame.Surface((25, 100))
surf.fill((255, 255, 255))
surf.set_colorkey((255, 0, 0))
bigger = pygame.Rect(0, 0, 25, 100)
pygame.draw.rect(surf, (100, 0, 0), bigger)
rotatedSurf = pygame.transform.rotate(surf, degree)
screen.blit(rotatedSurf, (400, 300))

running = True
while running:
    event = pygame.event.poll()
    if event.type == pygame.QUIT:
        running = False
    pygame.display.flip()
Run Code Online (Sandbox Code Playgroud)

我可以改变度数以获得不同的旋转但旋转大约是中心.我想将矩形中心以外的点设置为旋转点.

python pygame rotation python-2.7

6
推荐指数
4
解决办法
3710
查看次数

标签 统计

pygame ×1

python ×1

python-2.7 ×1

rotation ×1