Python/Pygame:将文本放置在特定位置

Python/Pygame:将文本放置在特定位置,python,pygame,python-3.4,Python,Pygame,Python 3.4,在我的代码中,我试图在特定位置放置一个文本框 screen = pygame.display.set_mode((1000, 600), 0, 32) #Set the window to 1000x600 WHITE = (255, 255, 255) BLUE = (0, 0, 255) text = font.render('Start', True, BLACK) textRect = text.get_rect() 最后一行的作用是什么?我如何修改此代码,以便将文本放置在特定(x

在我的代码中,我试图在特定位置放置一个文本框

screen = pygame.display.set_mode((1000, 600), 0, 32) #Set the window to 1000x600

WHITE = (255, 255, 255)
BLUE = (0, 0, 255)

text = font.render('Start', True, BLACK)
textRect = text.get_rect()

最后一行的作用是什么?我如何修改此代码,以便将文本放置在特定(x,y)坐标处?

如果获得与渲染曲面关联的矩形,请按如下方式更改位置:

textRect.center = (center_x, center_y) # set center to (x, y) coordinates
此外,请确保您正在更新屏幕并在游戏循环中绘制曲面:

while True:
    pygame.display.flip()
    screen.blit(text, textRect)

    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()

谢谢您的回答。否决票通常与其原因有关。您所说的“…修改此代码以便放置此代码…”是什么意思?你的意思是说别的而不是两次“代码”吗?是的,我的意思是
这样文本就被放置了…
lol谢谢你抓住了