我想将图像居中放置在rect内部,请注意,我正在使用图像rect,但是安装了适当的rect才能安装图像。
rect_1 = pygame.Rect(1, 1, 178, 178)
...
cross = pygame.image.load("cross.png").convert_alpha()
cross_minified = pygame.transform.rotozoom(cross, 0, 0.25)
...
screen.blit(cross_minified, rect_1)
答案 0 :(得分:2)
使用pygame.Rect
的功能。从center
的中心开始,得到一个图像大小为pygame.Surface.get_rect
的矩形,并通过关键字参数rect_1
设置其中心:
cross_rect = cross_minified.get_rect(center = rect_1.center)
screen.blit(cross_minified, cross_rect)