Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/321.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和livewires(尽管我认为这一部分与此无关)创建一个游戏。我已经让游戏正常运行了,但我正在尝试在游戏开始前制作类似于标题屏幕的东西。但是,当我尝试显示新行时,它无法识别。以下是我所拥有的: begin_message=games.Message(value=""" Destroy the Bricks!\n In this game, you control a paddle,\

我正在使用pygame和livewires(尽管我认为这一部分与此无关)创建一个游戏。我已经让游戏正常运行了,但我正在尝试在游戏开始前制作类似于标题屏幕的东西。但是,当我尝试显示新行时,它无法识别。以下是我所拥有的:

    begin_message=games.Message(value="""      Destroy the Bricks!\n
                                    In this game, you control a paddle,\n
                                    controlled by your mouse,\n
                                    and attempt to destroy all the rows of bricks.\n
                                    Careful though, you only have 1 life.\n
                                    Don't mess up! The game will start in\n
                                    5 seconds.""",
                            size=30,
                            x=games.screen.width/2,
                            y=games.screen.height/2,
                            lifetime=500,
                            color=color.white,
                            is_collideable=False)
games.screen.add(begin_message)

消息出现在屏幕上,但换行符没有出现,因此我只能阅读消息的第一部分。有没有办法使此消息实际出现,或者我不能使用“消息”来执行此操作?

livewires游戏。消息类无法执行此操作

浏览games.Message的源代码,显示它继承自games.Text,后者有一个方法_create_surface()。最后,调用pygame.font.font.render()将文本绘制到曲面上。如果你看一下,它说

“文本只能是一行: 不呈现换行符。“

至于如何做自己想做的事情,我建议创建几个消息对象,每行一个。然后在屏幕上一个接一个地显示它们。

在该网站上有几个用于pygame的。有些是python模块(您可以在本地包含该文件,而无需安装)


更高级的是

或者使用包含多个Message()实例的列表。