【发布时间】:2017-08-09 15:22:31
【问题描述】:
我的代码运行良好,尽管我完全不知道为什么。
我的代码是:
def textobjects(message, font,color):
Textsurface = font.render(message, True, color)
return Textsurface, Textsurface.get_rect()
def Display_text(message,color):
Heading = pygame.font.SysFont("Arial",70)
TextShown, Textrect = textobjects(message, Heading,color)
Textrect.center = ((displaywidth/2),0)
gameWindow.blit(TextShown,Textrect)
pygame.display.update()
time.sleep(2)
game_loop()
def border():
Display_text("You hit the border",wine)
我不知道为什么我能做到:
Textrect.center = ((displaywidth/2),0)
无需定义“.center”。 .center 是 pygame/python 预定义模块吗?
【问题讨论】:
-
是的,pygame.Rect 有一种叫做 center 的态度。但我强烈建议你从一个最基本的例子开始
-
这不完全是我的代码,不。我只是在看一个视频教程,很想知道它为什么会起作用。感谢您的回复。
-
我在哪里可以找到初学者(我自己)的基本示例?
-
@chubel 这里有两个链接会有所帮助:pygame.org/docs/tut/newbieguide.html 和 pygame.org/docs
-
我很感激。