Pygame 标志不变

Pygame logo doesn't change

所以我尝试更改 pygame 的图标但它没有改变,只显示默认的蛇。我用另一个徽标尝试过它并且它有效,但我无法弄清楚为什么那个有效而我想要的那个无效。有人可以帮忙吗?

代码:

gameIcon = pygame.image.load('path\icon.png')

pygame.display.set_icon(gameIcon)

谢谢!

顺便说一句,图片大小为 200x200,有效的是 512x512

参见pygame.display.set_icon()

[...] Some systems do not allow the window icon to change after it has been shown. This function can be called before pygame.display.set_mode() to create the icon before the display mode is set.

设置pygame.display.set_mode()前的图标:

gameIcon = pygame.image.load('path\icon.png')
pygame.display.set_icon(gameIcon)

screen = pygame.display.set_mode((width, height))

好的,我将图标图像的大小调整为 512x512,现在可以使用了。非常感谢!