showScreen = True
if showScreen == True:
display = pygame.display.set_mode((500, 200))
pygame.display.set_caption("Decision Bar Window")
decisionBarImage = pygame.image.load('D:/Adriel/Documents/Python stuff/Games/Basic python game/Images/decision_bar.png')
pygame.display.flip
display.blit(decisionBarImage, (250,100))
在我的代码中,窗口将会打开,但图像不会显示在窗口上。请帮帮忙。
发布于 2020-02-27 22:17:58
在调用pygame.display.flip()
之前,您必须将图像blit到屏幕表面。
然后,您必须实际调用flip()
函数。在您的代码中,()
丢失了。
此外,您还需要一个事件循环,否则您的窗口将冻结或可能不显示任何内容。
因此,您的代码应该如下所示:
display = pygame.display.set_mode((500, 200))
pygame.display.set_caption("Decision Bar Window")
decisionBarImage = pygame.image.load('D:/Adriel/Documents/Python stuff/Games/Basic python game/Images/decision_bar.png')
display.blit(decisionBarImage, (250,100))
while True:
for e in pygame.event.get():
pass # TODO: handle at least the QUIT event
pygame.display.flip()
https://stackoverflow.com/questions/60434055
复制相似问题