【发布时间】:2023-01-11 02:18:03
【问题描述】:
我已经尝试了很多,但仍然不明白为什么它不加载按钮。
import pygame
pygame.init()
screen = pygame.display.set_mode((3840,2160))
running = True
mouse = pygame.mouse.get_pos()
pygame.display.set_caption("GermanBall")
bg = pygame.image.load("Tan.jpg")
icon = pygame.image.load("box.png")
button1 = pygame.image.load("shirt.png").convert_alpha()
class Button():
def __init__(self,x,y,image):
self.image = image
self.rect = self.image.get_rect()
self.rect.topleft = (x,y)
def draw(self):
screen.blit(self.image,(self.rect.x,self.rect.y))
start = Button(0,0,button1)
pygame.display.set_icon(icon)
while running == True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
start.draw()
screen.blit(bg,(0,0))
pygame.display.update()
我想让按钮加载。它没有给我一个错误,只是不加载。
【问题讨论】:
-
screen.blit(bg,(0,0))立即擦除您绘制的所有内容。