【问题标题】:Color not changes [duplicate]颜色不变[重复]
【发布时间】:2020-12-03 17:58:55
【问题描述】:
import pygame 
import random 
pygame.init()
screen=pygame.display.set_mode((1600,900))
screen.fill((100,100,200))
running=True
while running:
    for event in pygame.event.get():
        if event.type=pygame.QUIT:
            running=False

【问题讨论】:

  • 仅供参考,我修复了代码的格式,但没有缩进或间距,所以我无法知道我是否保留了它。我假设它在你的机器上是正确的。
  • 问题解决了吗?

标签: python pygame pycharm


【解决方案1】:

您错过了通过pygame.display.update()pygame.display.flip() 更新显示。

典型的 PyGame 应用程序循环必须:

while running:
    for event in pygame.event.get():
        if event.type=pygame.QUIT:
            running=False

    screen.fill((100,100,200))

    pygame.display.flip()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-29
    • 2016-02-12
    • 1970-01-01
    • 2014-03-01
    • 2017-11-14
    • 2021-11-10
    • 2016-01-26
    • 1970-01-01
    相关资源
    最近更新 更多