enteracity
json_wuwu
2019-03-17 23:25

python3,windos7系统提示AttributeError: 'Feijidazhan' object has no attribute 'back_group'

  • python

1AttributeError: 'Feijidazhan' object has no attribute 'back_group'

```class Feijidazhan(object):
def init(self):
print("初始化游戏")
#1创建游戏窗口
self.feiji_mode = pygame.display.set_mode(DA_XIAO.size)
#2 创建游戏时钟
self.clock = pygame.time.Clock()
#3私有方法精灵和精灵组的创建
def spirit_jiling(self):
#1背景滚动
beijing = Bjinjing(".\images\background.png")
self.back_group = pygame.sprite.Group(beijing)

def start_game(self):#开始游戏
    print("开始游戏")
    while True:
        # 1刷新帧率
        self.clock.tick(ZHEN_LV)
    # 2事件监听
        self.__jian_ting()
    # 3碰撞检测
        self.__peng_zhuang()
    # 4更新绘制精灵,英雄
        self.__hui_zhi()

    # 5更新显示
        pygame.display.update()
def __jian_ting(self):
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            Feijidazhan.__game_over()

def __peng_zhuang(self):

    pass
def __hui_zhi(self):
    self.back_group.update()
    self.back_group.draw(self.feiji_mode)

@staticmethod
def __game_over():
    print("游戏结束")
    pygame.quit()
    exit()

if name == '__main__':
#创建对象
game_ = Feijidazhan()
#启动游戏

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答