我想在基本游戏的背景上添加颜色,但是我一直收到无效的颜色参数
我已尝试完全删除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
答案 0 :(得分:2)
fill
仅接受一个论点。并且bg_color
不是ai_settings
的属性。您需要将行更改为:
screen.fill(bg_color)