What is the difference between screen.blit(player, (xpos, ypos)) and display.flip() in pygame?

元气小坏坏 提交于 2019-12-02 07:23:42

问题


Both appear to update either the entire screen or just a section of the screen, but which does what and how?


回答1:


blit() doesn't update screen - it draws image in buffer.

update()/flip() sends buffer to video card which displays it on monitor.

If you have code with blit() but without update()/flip() the it will display nothing.


flip() sends all buffer to video card. Probably it can use optimized method to do it fast.

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.

See doc: update(), flip()




来源:https://stackoverflow.com/questions/47335588/what-is-the-difference-between-screen-blitplayer-xpos-ypos-and-display-fli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!