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