12.6.5设置飞船的活动范围 AttributeError: ‘pygame.Rect‘ object has no attribute ‘down‘

class Character():
    # Other methods...

    def update(self):
        # Other if clauses...
        if self.moving_up and self.rect.up < self.screen_rect.up:
            self.center1 += self.ai_settings.char_speed_factor
        if self.moving_down and self.rect.down > 0:
            self.center1 -= self.ai_settings.char_speed_factor
        # ...

这是报错的代码

if self.moving_up and self.rect.top > 0:
    self.center1 -= self.ai_settings.char_speed_factor
if self.moving_down and self.rect.bottom < self.screen_rect.bottom:
    self.center1 += self.ai_settings.char_speed_factor

这是修改后的

因为 pagame 里表示 下边 上边 左边 右边 分别是 

midbottom midbotop midleft midright
上一篇:字符串题目:HTML 实体解析器


下一篇:实验 | Java Web开发从入门到实战