User interface 如何在pygame gui中向按钮添加背景图像?
我试图在pygame gui中添加一个图像作为按钮的背景。我现在已经创建了按钮,我只需要添加图像。如何将图像添加到按钮 这是我的密码User interface 如何在pygame gui中向按钮添加背景图像?,user-interface,button,background,pygame,User Interface,Button,Background,Pygame,我试图在pygame gui中添加一个图像作为按钮的背景。我现在已经创建了按钮,我只需要添加图像。如何将图像添加到按钮 这是我的密码 game1 = pygame.Rect(150 , 100, 200, 150) # creates a rect object pygame.draw.rect(screen, [255, 100, 0], game1) # draw objects down here 它工作正常您可能正在寻找pygame.Surface.blit() 加载你的背
game1 = pygame.Rect(150 , 100, 200, 150) # creates a rect object
pygame.draw.rect(screen, [255, 100, 0], game1) # draw objects down here
它工作正常您可能正在寻找
pygame.Surface.blit
()
加载你的背景图像,并在任何你想要的地方进行blit
img = pygame.image.load('thisisanimage.png')
WhateverYourDisplayNameIs.blit(img,(x,y))
为了防止您感到困惑,您似乎正在使用
屏幕
作为显示界面。您能帮我一个忙并给我看一个代码示例吗?@larry别忘了给您的按钮图像命名按钮\u img
非常感谢,这帮了大忙