如何更改 pygame 图标? [英] How do I change the pygame icon?
问题描述
有谁知道如何更改 pygame 图标?我在 pygame 网站上找到了一个可以让你这样做的东西,但是当我尝试它时,它只会让 pygame 窗口变得非常小.
先将图标图片加载为一个表面,然后使用pygame.display.set_icon(surface)
改变图标.>
由于提问者不知道表面是什么
来自 http://www.pygame.org/docs/ref/的文档表面.html
一个 pygame Surface 用于表示任何图像.Surface 具有固定的分辨率和像素格式.调用 pygame.Surface() 来创建一个新的图像对象."
例如,如果您使用 screen = pygame.display.set_mode
,screen
是一个表面.
因此,当使用 pygame.display.set_icon(surface)
时,您必须首先使用 a = pygame.image.load('image')<将图像作为 pygame.Surface 导入/code> 其中
a
是将存储表面的变量,'image'
是该图像的目录.然后您可以使用 pygame.display.set_icon(surface)
为图标设置 a.您可以通过任何表面,但最好是 32x32.
此处的更多信息:http://www.pygame.org/docs/ref/display.html#pygame.display.set_icon
Does anyone know how to change the pygame icon? I found a thing on the pygame website that lets you do this, but when I try it, it just makes the pygame window very small.
First load the icon image as a surface, then use pygame.display.set_icon(surface)
to change the icon.
EDIT: Since the asker doesn't know what a surface is
From the docs at http://www.pygame.org/docs/ref/surface.html
"A pygame Surface is used to represent any image. The Surface has a fixed resolution and pixel format. Call pygame.Surface() to create a new image object."
For example, if you used screen = pygame.display.set_mode
, screen
is a surface.
So when using pygame.display.set_icon(surface)
you must first import an image as a pygame.Surface by using a = pygame.image.load('image')
where a
is the variable the surface will be stored and 'image'
is the directory to that image. Then you can set a to the icon by using pygame.display.set_icon(surface)
. You can pass any surface, but it is desirable that it is 32x32.
More information here: http://www.pygame.org/docs/ref/display.html#pygame.display.set_icon
这篇关于如何更改 pygame 图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!