Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Pygame口袋妖怪风格的文本显示_Python_Pygame - Fatal编程技术网

Python Pygame口袋妖怪风格的文本显示

Python Pygame口袋妖怪风格的文本显示,python,pygame,Python,Pygame,我已经看过一些教程,其中一个是在pygame窗口中延迟放置文本,使其看起来就像是在口袋妖怪游戏中一样。然而,我很难直接将其插入窗口,而不是将其插入“矩形”形状。程序不会显示任何错误,运行正常,但文本也不会显示在屏幕上 def display_text_animation(string): #Here is the function for animating the text text = '' for i in range(len(string)): text += string[

我已经看过一些教程,其中一个是在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.

调用
font.render
,它将返回存储在
text\u Surface
变量中的
Surface


但是您不需要使用这个新的
曲面
。在调用
pygame.display.update()
调用
font.render
之前,必须将其快速放到显示器
Surface
上,这将返回存储在
text\u Surface
变量中的
Surface


但是您不需要使用这个新的
曲面
。在调用
pygame.display.update()

之前,您必须将其快速放到显示器
Surface
上?我看不到您在任何地方引用
文本
。@Jerome Indefenzo抱歉,我忘了添加渲染线。我的坏蛋。。。现在可以了吗?到底是哪一部分在渲染文本?我看不到您在任何地方引用
文本
。@Jerome Indefenzo抱歉,我忘了添加渲染线。我的坏蛋。。。现在能用了吗?抱歉,我该怎么做呢?感谢您对@slothApologies的帮助,但我该怎么做呢?谢谢你的帮助@sloth