如何从Pygame列表中绘制矩形
它说rect参数是无效的
,但是当我给出相同的rect而无需变量时,这是负责它的代码的一部分,
class Background:
def __init__(self, background):
self.background = background
self.endpoint = 5590
self.bx = 0
self.scrolling_right = False
self.scrolling_right = True
self.obstacleses = []
def obstacles(self):
self.obstacleses = pygame.Rect(300, 300, 20, 60)
print(self.obstacleses)
def surface(self):
screen.blit(self.background, (self.bx, 0))
screen.blit(templar1.image, templar1.pos)
screen.blit(Rogue.image, Rogue.pos)
pygame.draw.rect(screen, (255, 0, 0), self.obstacleses)
pygame.display.update()
我也尝试了self.obstacleses(0)在
pygame.draw.Rect
中,但随后我获得列表对象不是可呼叫
。
It says rect argument is invalid
but when I give the same rect without a variable it works, here is the part of a code responsible for it
class Background:
def __init__(self, background):
self.background = background
self.endpoint = 5590
self.bx = 0
self.scrolling_right = False
self.scrolling_right = True
self.obstacleses = []
def obstacles(self):
self.obstacleses = pygame.Rect(300, 300, 20, 60)
print(self.obstacleses)
def surface(self):
screen.blit(self.background, (self.bx, 0))
screen.blit(templar1.image, templar1.pos)
screen.blit(Rogue.image, Rogue.pos)
pygame.draw.rect(screen, (255, 0, 0), self.obstacleses)
pygame.display.update()
I also tried self.obstacleses(0)
in pygame.draw.rect
but then i get list object is not callable
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须在循环中绘制矩形:
You have to draw the rectangles in a loop: