问题描述
这两者似乎都可以更新整个屏幕或仅更新屏幕的一部分,但是哪个屏幕可以更新内容呢?
Both appear to update either the entire screen or just a section of the screen, but which does what and how?
推荐答案
blit()
不更新屏幕-它在缓冲区中绘制图像。
blit()
doesn't update screen - it draws image in buffer.
update()/ flip()
将缓冲区发送到显示在监视器上的视频卡。
update()/flip()
sends buffer to video card which displays it on monitor.
如果您的代码带有 blit()
但没有 update()/ flip()
它将什么也不显示。
If you have code with blit()
but without update()/flip()
the it will display nothing.
flip()
将所有缓冲区发送到视频卡。
flip()
sends all buffer to video card. Probably it can use optimized method to do it fast.
update()
可以使用<$ c $获得列表。 c> Rect()并仅发送缓冲区的一部分,这样可能会更快。但是您必须知道要更换的零件。有时很难正确选择要更新的区域。
update()
can get list with Rect()
and sends only some part of buffer so it could be faster. But you have to know which parts you what to replace. Sometimes it is hard to correctly choose which areas to update.
请参阅文档:,
这篇关于pygame中screen.blit(player,(xpos,ypos))和display.flip()有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!