首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >python错误消息AttributeError:'Bird‘对象没有'unsetflapped’属性

python错误消息AttributeError:'Bird‘对象没有'unsetflapped’属性
EN

Stack Overflow用户
提问于 2021-08-08 05:19:15
回答 1查看 36关注 0票数 0

因此,我正在学习从视频编码教程系列中编写游戏代码。我目前的问题是,当我运行游戏时,我得到了以下错误:

文件更新self.unsetflapped() AttributeError中的第33行:‘"/home/dev/PycharmProjects/Game6_Flappy_Bird/modules/sprites/bird.py",’对象没有'unsetflapped‘属性。

代码来自"bird class sprites file code:

代码语言:javascript
复制
self.is_flapped = False
    self.down_speed = 0
    self.up_speed = 9

    self.bird_idx = idx
    self.bird_idx_cycle = itertools.cycle([0,1,2,1])
    self.bird_idx_change_count = 0

def update(self, boundary_values, time_passed):

    if self.is_flapped:
        self.up_speed -= 60 * time_passed
        self.rect.top -= self.up_speed

        if self.up_speed <= 0:
            self.unsetflapped()
            self.up_speed = 9
            self.down_speed = 0
    else:
        self.down_speed += 40*time_passed
        self.rect.bottom += self.down_speed

    is_dead = False

    if self.rect.bottom > boundary_values[1]:
        is_dead = True
        self.up_speed = 0
        self.down_speed = 0
        self.rect.bottom = boundary_values[1]
    if self.rect.top < boundary_values[0]:
        is_dead = True
        self.up_speed = 0
        self.down_speed = 0
        self.rect.top = boundary_values[1]
    self.bird_idx_change_count +=1
    if self.bird_idx_change_count%5 == 0:
        self.bird_idx = next(self.bird_idx_cycle)
        self.image = list(self.images.values())[self.bird_idx]
        self.bird_idx_change_count = 0
    return is_dead

def setFlapped(self):
    if self.is_flapped:
        self.up_speed = max(12, self.up_speed+1)
    else:
        self.is_flapped = True

def unsetFlapped(self):
    self.is_flapped = False

我已经根据导师提供的源代码进行了检查,它完全匹配,所以我希望有人能指出我做错了什么。

EN

回答 1

Stack Overflow用户

发布于 2021-08-08 05:38:46

请注意:我发现了我的问题。字母的大写。我需要把小写的"f“改成大写的"F”

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68698001

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档