Python pygame.Surface.get_rect()的关键参数是什么?

Python pygame.Surface.get_rect()的关键参数是什么?,python,pygame,Python,Pygame,在编程课程中,我正在学习使用pygame,但我对pygame.Surface.get_rect()方法感到困惑。我看到它可以接受一些关键字参数,但我在任何地方都找不到它们是什么。我看到了get_rect(center=(num,num)),但我正在尝试分配左上角的坐标。有没有办法做到这一点?将关键字参数应用于rect的属性。这些记录在: Rect对象有几个虚拟属性,可用于 移动并对齐矩形: x,y top, left, bottom, right topleft, bottomleft, top

在编程课程中,我正在学习使用
pygame
,但我对
pygame.Surface.get_rect()
方法感到困惑。我看到它可以接受一些关键字参数,但我在任何地方都找不到它们是什么。我看到了
get_rect(center=(num,num))
,但我正在尝试分配左上角的坐标。有没有办法做到这一点?

将关键字参数应用于rect的属性。这些记录在:

Rect对象有几个虚拟属性,可用于 移动并对齐矩形:

x,y
top, left, bottom, right
topleft, bottomleft, topright, bottomright
midtop, midleft, midbottom, midright
center, centerx, centery
size, width, height
w,h
所有这些属性都可以指定给:

rect1.right = 10
rect2.center = (20,30)
指定为“大小”、“宽度”或“高度”会更改图形的尺寸 长方形所有其他指定移动矩形而不调整大小 信息技术请注意,某些属性是整数,而其他属性是成对的 整数

因此,如果您想要得到一个与图像大小相同的矩形,且其左上角位于某一点,您可以执行以下操作:

my_surface.get_rect(topleft=some_point)
您还可以传递单独的
top
left
参数(或
x
y