如何捕获pygame屏幕? [英] How to capture pygame screen?
本文介绍了如何捕获pygame屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何捕获和保存 pygame 屏幕的一系列图像或视频?
基本上我想在youtube上分享我的游戏视频.还有,想做个教程.
How can I capture and save a sequence of images or a video of a pygame screen?
Basically I want to share my game video on youtube. Also, want to make a tutorial.
游戏主要在一个循环中渲染:
The game is rendered mainly in a loop:
def main():
while True:
GetInput()
Move()
Shift()
Draw()
使用 Draw()
函数在执行 pygame.display.flip()
之前完成所有的 blit()
和其他东西>
With the Draw()
function doing all the blit()
and stuff before doing the pygame.display.flip()
推荐答案
在屏幕表面使用 pygame.image.save
:
window = pygame.display.set_mode(...)
...
pygame.image.save(window, "screenshot.jpeg")
请注意,这会极大地减慢您的程序速度.如果是基于时间的,您可能希望在进行捕获时伪造帧率.
Note that this will slow down your program tremendously. If it is time-based, you may wish to fake the framerate when doing a capture.
这篇关于如何捕获pygame屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文