pygame.display.update 和 pygame.display.flip 的区别 [英] Difference between pygame.display.update and pygame.display.flip

查看:769
本文介绍了pygame.display.update 和 pygame.display.flip 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所暗示的那样,有什么区别吗?我使用的是 pygame.display.flip,我在 Internet 上看到他们使用 pygame.display.update 而不是使用翻页.哪个更快?

Just like the title implies, is there any difference? I was using pygame.display.flip and I saw on the Internet that instead of using flip they used pygame.display.update. Which one is faster?

推荐答案

pygame.display.flippygame.display.update 就是

  • display.flip() 将更新整个显示的内容
  • display.update() 允许更新屏幕的一部分,而不是整个屏幕区域.不传递参数,更新整个显示

要告诉 PyGame 它应该更新屏幕的哪些部分(即在您的显示器上绘制),您可以传递一个 pygame.Rect 对象,或者它们的序列到 display.update() 函数.PyGame 中的 Rect 存储 widthheight 以及 x- 和 y- 坐标,用于位置.

To tell PyGame which portions of the screen it should update (i.e. draw on your monitor) you can pass a single pygame.Rect object, or a sequence of them to the display.update() function. A Rect in PyGame stores a width and a height as well as a x- and y-coordinate for the position.

PyGame 的 内置黎明功能.blit() 方法例如返回一个 Rect,因此您可以简单地将其传递给 display.update() 函数,以便仅更新新"绘制区域.

PyGame's built-in dawning functions and the .blit() method for instance return a Rect, so you can simply pass it to the display.update() function in order to update only the "new" drawn area.

由于与 display.flip() 相比,display.update() 仅更新整个屏幕的某些部分, display.update() 在大多数情况下速度更快.

Due to the fact that display.update() only updates certain portions of the whole screen in comparison to display.flip(), display.update() is faster in most cases.

这篇关于pygame.display.update 和 pygame.display.flip 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆