简体   繁体   English

如何在Pygame中将闪屏图像保留在屏幕上5秒钟?

[英]How to make a splash screen image stay on screen for 5 seconds in Pygame?

I have a simple Pygame game which I need to create a splash screen for that displays the game name for 5 seconds. 我有一个简单的Pygame游戏,我需要创建一个启动画面,显示游戏名称5秒钟。 This is currently being achieved by blitting some standard text to the display surface and calling pygame.time.delay(5000). 目前,这是通过将一些标准文本blit到显示器表面并调用pygame.time.delay(5000)来实现的。 However, whilst the 5 seconds elapse my game does not seem to be capturing any events. 然而,虽然经过了5秒钟,我的游戏似乎没有捕获任何事件。 The event procedure is located in a while True: loop below the splash screen function but it is obvious that pygame.time.delay() is freezing my entire code... but I need the event procedure to still function so I can detect quit /escape key (to skip the splash screen) events. 事件过程位于启动屏幕功能下面的一段时间True:循环但显然pygame.time.delay()冻结了我的整个代码......但我需要事件过程仍然起作用所以我可以检测退出/ escape键(跳过启动画面)事件。

Thanks in advance, Ilmiont 提前谢谢,Ilmiont

With Pygame you can use the pygame.time.get_ticks function when the splash screen appears and record this time. 使用Pygame,您可以在出现闪屏时使用pygame.time.get_ticks函数并记录此时间。 Continue getting input from the user and calling get_ticks to see if 5000 milliseconds have elapsed and when it has you may discontinue the splash screen and continue as normal. 继续从用户那里获取输入并调用get_ticks以查看是否已经过了5000毫秒,何时可以停止启动屏幕并继续正常运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM