求助-关于pygame
def __main_menu(self):# self.fill = pygame.draw.rect(self.screen,pygame.Color('red'),(0,0,800,600),0)
# self.text_rect = self.fonts.render_to(self.screen,(200,160),'TEST TEXT',fgcolor=(190,190,190),size=50)
# set background image
background = pygame.image.load(
r'..\..\resources\images\MainMenu.png').convert()
self.screen.blit(pygame.transform.scale(
background, (1280, 720)), (0, 0))
self.history_size = width, height = 1280, 720
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.VIDEORESIZE:
if event.size/0.5625 == event.size:
self.screen.blit(pygame.transform.scale(
background, (event.size, event.size)), (0, 0))
self.history_size = width, height = event.size, event.size
elif event.size == self.history_size:
self.screen = pygame.display.set_mode(
(event.size, int(event.size*0.5625)), pygame.RESIZABLE, 32)
self.screen.blit(pygame.transform.scale(
background, (event.size, int(event.size*0.5625)), (0, 0))
self.history_size=width, height=event.size, int(
event.size*0.5625) #就是提示这段代码有问题
#具体显示:
#
#G:\xxx>D:/Software/Python/python.exe "g:/xxx/Libs/DisplayContent/mainloop.py"
#File "g:\xxx\Libs\DisplayContent\mainloop.py", line 92
# self.history_size=width, height=event.size, int(
# ^
#SyntaxError: invalid syntax
#
elif event.size == self.history_size:
self.screen=pygame.display.set_mode(
(int(event.size/0.5625), event.size), pygame.RESIZABLE, 32)
self.screen.blit(pygame.transform.scale(
background, (int(event.size/0.5625), event.size)), (0, 0))
self.history_size=width, height=int(
event.size/0.5625), event.size
else:
continue
pygame.display.update()
这个显示self.history_size使用错误的语法,但是我压根找不出哪里有问题,希望有带佬可以康康
PS:代码截自脚本中一个单独的类 def __main_menu(self):
# self.fill = pygame.draw.rect(self.screen,pygame.Color('red'),(0,0,800,600),0)
# self.text_rect = self.fonts.render_to(self.screen,(200,160),'TEST TEXT',fgcolor=(190,190,190),size=50)
# set background image
background = pygame.image.load(
r'..\..\resources\images\MainMenu.png').convert()
self.screen.blit(pygame.transform.scale(
background, (1280, 720)), (0, 0))
self.history_size = width, height = 1280, 720
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.VIDEORESIZE:
if event.size/0.5625 == event.size:
self.screen.blit(pygame.transform.scale(
background, (event.size, event.size)), (0, 0))
self.history_size = width, height = event.size, event.size
elif event.size == self.history_size:
self.screen = pygame.display.set_mode(
(event.size, int(event.size*0.5625)), pygame.RESIZABLE, 32)
self.screen.blit(pygame.transform.scale(
background, (event.size, int(event.size*0.5625)), (0, 0)))
self.history_size=width, height=event.size, int(
event.size*0.5625) #就是提示这段代码有问题
#具体显示:
#
#G:\xxx>D:/Software/Python/python.exe "g:/xxx/Libs/DisplayContent/mainloop.py"
#File "g:\xxx\Libs\DisplayContent\mainloop.py", line 92
# self.history_size=width, height=event.size, int(
# ^
#SyntaxError: invalid syntax
#
elif event.size == self.history_size:
self.screen=pygame.display.set_mode(
(int(event.size/0.5625), event.size), pygame.RESIZABLE, 32)
self.screen.blit(pygame.transform.scale(
background, (int(event.size/0.5625), event.size)), (0, 0))
self.history_size=width, height=int(
event.size/0.5625), event.size
else:
continue
pygame.display.update()少半个括号 永恒的蓝色梦想 发表于 2020-11-13 22:04
少半个括号
有吗,没看到哪里有少括号,在哪一行? ink_Ocelot 发表于 2020-11-13 22:08
有吗,没看到哪里有少括号,在哪一行?
42行 永恒的蓝色梦想 发表于 2020-11-13 22:21
42行
谢谢!
页:
[1]