【问题标题】:What is the difference between screen.blit(player, (xpos, ypos)) and display.flip() in pygame?pygame 中的 screen.blit(player, (xpos, ypos)) 和 display.flip() 有什么区别?
【发布时间】:2018-04-30 08:11:47
【问题描述】:

两者似乎都更新整个屏幕或仅更新屏幕的一部分,但哪个做什么以及如何?

【问题讨论】:

    标签: python pygame display flip blit


    【解决方案1】:

    blit() 不更新屏幕 - 它在缓冲区中绘制图像。

    update()/flip() 将缓冲区发送到显示在监视器上的视频卡。

    如果您有带有blit() 但没有update()/flip() 的代码,它将不会显示任何内容。


    flip() 将所有缓冲区发送到显卡。可能它可以使用优化的方法快速完成。

    update() 可以使用Rect() 获取列表,并且只发送缓冲区的一部分,这样可以更快。但是您必须知道要更换哪些零件。有时很难正确选择要更新的区域。

    见文档:update(), flip()


    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-03
    • 1970-01-01
    • 2021-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    相关资源
    最近更新 更多