Pygame 不会让我画圆错误参数 3 必须是长度为 2 而不是 4 的序列 [英] Pygame Wont Let Me Draw A Circle Error argument 3 must be sequence of length 2, not 4

查看:53
本文介绍了Pygame 不会让我画圆错误参数 3 必须是长度为 2 而不是 4 的序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用 pygame 画一个圆圈,但我不断收到此错误

I am trying to draw a circle with pygame but I keep getting this error

error  argument 3 must be sequence of length 2, not 4

class circle:
    def __init__(self,x,y,height,width,color):
        self.x =x
        self.y = y
        self.height = height
        self.width  = width
        self.color = color
        self.rect = pygame.Rect(x,y,height,width)
    def draw(self):
        self.rect.topleft = (self.x,self.y)
        pygame.draw.circle(window,self.color,self.rect,20)
circle1 = circle(300,200,20,20,white)

推荐答案

pygame.draw.circle 是圆的中心点,而不是矩形:

The 3rd argument of pygame.draw.circle is the center point of the circle, rather than a rectangle:

pygame.draw.circle(window,self.color,self.rect,20)

pygame.draw.circle(window, self.color, self.rect.center, 20)

这篇关于Pygame 不会让我画圆错误参数 3 必须是长度为 2 而不是 4 的序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆