如何使我的 pygame 游戏窗口可调整大小? [英] How to make my pygame game window resizeable?
本文介绍了如何使我的 pygame 游戏窗口可调整大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我运行此代码时,可调整大小选项可用,但是当我单击它以最大化屏幕时,会出现这个奇怪的白色轮廓.我该如何解决?.
When I run this code the resizeable option is available but when I click on it to maximize the screen, there is this weird white outline that appears. How would I fix it?.
import pygame
pygame.init()
screen = pygame.display.set_mode((900, 500), pygame.RESIZABLE)
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.display.update()
推荐答案
你必须重新创建显示 Surface
(参见 pygame.event
):
You have to recreate the display Surface
in the VIDEORESIZE
event (see pygame.event
):
import pygame
pygame.init()
screen = pygame.display.set_mode((900, 500), pygame.RESIZABLE)
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.VIDEORESIZE:
screen = pygame.display.set_mode(event.size, pygame.RESIZABLE)
pygame.display.update()
这篇关于如何使我的 pygame 游戏窗口可调整大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文