颜色参数无效

时间:2019-07-21 20:14:50

标签: python pygame

我想在基本游戏的背景上添加颜色,但是我一直收到无效的颜色参数

我已尝试完全删除bg_color,但仍然出现相同的错误

def run_game():
  pygame.init()
  ai_settings = Settings()
  screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
  pygame.display.set_caption("First Game")
  ship = Ship(screen)
  bg_color = (230, 230, 230)

  while True:
      check_events(ship)
      ship.update()
      screen.fill(ai_settings, bg_color)
      ship.blitme()
      pygame.display.flip()
      for event in pygame.event.get():
          if event.type==pygame.QUIT:
              sys.exit()
      screen.fill(ai_settings.bg_color)
      ship.blitme()
      pygame.display.flip()
run_game()
File "C:/Users/Areeb Irfan/.PyCharmCE2018.3/config/scratches/AlienGame.py", line 40, in <module>
run_game()
File "C:/Users/Areeb Irfan/.PyCharmCE2018.3/config/scratches/AlienGame.py", line 31, in run_game
screen.fill(ai_settings, bg_color)
TypeError: invalid color argument

1 个答案:

答案 0 :(得分:2)

fill仅接受一个论点。并且bg_color不是ai_settings的属性。您需要将行更改为:

screen.fill(bg_color)
相关问题