【问题标题】:Error: TypeError: circle() takes no keyword arguments错误:TypeError:circle() 没有关键字参数
【发布时间】:2020-12-19 23:18:12
【问题描述】:

我正在尝试创建一个游戏,其中包含需要在单击某处后添加的圆圈,其他代码行工作正常,只是代码行 pygame.draw.circle(win, white, (105-circle_radius/2, 105-circle_radius/2), radius=circle_radius) 返回错误:

TypeError: circle() takes no keyword arguments

代码:

import pygame
pygame.init()

white = (255, 255, 255)
player_details = []
circle_radius = 100
WIDTH = 500
HEIGHT = 500


win = pygame.display.set_mode((WIDTH, HEIGHT))

(irrelevant code here)

def insert_input(slot_num, marker):
    board[slot_num] = marker
    print(board)


def circle_placement(x, y):
    if (31 <= x <= 179) and (31 <= y <= 179):
        slot1 = 1
        if board[1] == " ":
            insert_input(slot1, player_details[1])
            pygame.draw.circle(win, white, (105-circle_radius/2, 105-circle_radius/2), radius=circle_radius
        if board[1] != " ":
            print("Turn passed for attempting to Cheat!")

(irrelevant code here)

我尝试了其他形状,一切正常,只是这个不起作用并返回错误:TypeError:circle() 没有关键字参数,我尝试将 'circle_radius' 更改为数字变量,但这不起作用,我尝试更改颜色,但也不起作用。

我没有从互联网上找到任何答案,从我的研究中,当我找到时,它们没有工作,所以我希望在这里找到答案。

【问题讨论】:

  • 请发布完整的错误回溯。

标签: python pygame geometry typeerror


【解决方案1】:

pygame.draw.circle()radius 参数不是关键字参数(删除 radius=):

pygame.draw.circle(win, white, (105-circle_radius/2, 105-circle_radius/2), radius=circle_radius)

pygame.draw.circle(win, white, (105-circle_radius/2, 105-circle_radius/2), circle_radius)

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-04-08
  • 1970-01-01
  • 2020-12-06
  • 1970-01-01
  • 1970-01-01
  • 2020-02-18
  • 1970-01-01
相关资源
最近更新 更多