拼图的问题是导入游戏的矩形

发布于 2025-01-28 11:20:50 字数 1488 浏览 5 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悲歌长辞 2025-02-04 11:20:50

绘制矩形后,您必须更新显示:

rect = pg.Rect(0, 0, 200, 100)
rect.center = (300, 300)

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

    # draw background
    screen.blit(background_image, [0, 0])
   
    # draw rectangle on top of the background 
    pg.draw.rect(screen, BLACK, rect)

    # update display
    pg.display.flip()

您实际上是在 surface 对象。如果您借鉴了与PyGame显示器关联的 surface ,则在显示屏中不立即可见。更改将可见,当显示显示使用 pygame.display.update() pygame.display.flip()

You have to update the display after drawing the rectangle:

rect = pg.Rect(0, 0, 200, 100)
rect.center = (300, 300)

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

    # draw background
    screen.blit(background_image, [0, 0])
   
    # draw rectangle on top of the background 
    pg.draw.rect(screen, BLACK, rect)

    # update display
    pg.display.flip()

You are actually drawing on a Surface object. If you draw on the Surface associated to the PyGame display, this is not immediately visible in the display. The changes become visible, when the display is updated with either pygame.display.update() or pygame.display.flip().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文