我已经看过一些教程,其中一个是在pygame窗口上放置文本的延迟,这样它看起来就像是在口袋妖怪游戏中一样。然而,我在直接对窗口执行此操作时遇到了问题,而不是将其插入到“矩形”形状中。程序不会显示任何错误,运行正常,但是文本也不会显示在屏幕上。
def display_text_animation(string): #Here is the function for animating the text
text = ''
for i in range(len(string)):
text += string[i]
text_surface = font.render(text, True, BLACK)
pygame.display.update()
pygame.time.wait(100)
def intro():
gameDisplay = displayBox()
progBg1 = pygame.image.load("introScr.png")
gameDisplay.blit(progBg1, (0,0))
display_text_animation('Hello World!') #here is where I call the text to appear.发布于 2016-10-21 20:35:22
调用font.render,它将返回存储在text_surface变量中的Surface。
但是你不需要对这个新的Surface做任何事情。在调用pygame.display.update()之前,您必须将它blit到display Surface上。
https://stackoverflow.com/questions/40173216
复制相似问题