[FIXED] AttributeError: 'bool' object has no attribute 'show_credits_heading'

Issue

I have made a simple app that lists the credits of a project I'm working on, it's just something fun I wanted to do that was out of the box. However when I run the program an error shows up. It says that "AttributeError: 'bool' object has no attribute 'show_credits_heading'" Which I have no idea why that is coming. Here is the code:

# Menu
Menu_Font = pygame.font.Font("8-BIT WONDER.TTF", 45)
Menu_HeadingX = 290
Menu_HeadingY = 70

Text_Font = pygame.font.Font("8-BIT WONDER.TTF", 25)

start_x, start_y = Menu_HeadingX, Menu_HeadingY+150
options_x, options_y = Menu_HeadingX, Menu_HeadingY+200
credits_x, credits_y = Menu_HeadingX, Menu_HeadingY+250

class credits_menu():
def show_credits_heading():
    Credits_Heading = Menu_Font.render("Credits", True, (255, 255, 255))
    screen.blit(Credits_Heading, (Menu_HeadingX, Menu_HeadingY))

def show_code_credit():
    Code_Credit = Text_Font.render("All Code: By Me", True, (255, 255, 255))
    screen.blit(Sound_Option, (start_x, start_y))

def show_idea_credit():
    Idea_Credit = Text_Font.render("Idea By Me", True, (255, 255, 255))
    screen.blit(Sound_Option, (options_x, options_y))
     
def show_img_credit():
    Img_Credit = Text_Font.render("Images: Taken from google", True, (255, 255, 255))
    screen.blit(Sound_Option, (credits_x, credits_y))

Main Problem is in:

while credits_menu:
    screen.fill((0,0,0))

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running, playing, credits_menu, options_menu = False, False, False, False

    screen.fill((0,0,0))
    credits_menu.show_credits_heading()
    credits_menu.show_code_credit()
    credits_menu.show_idea_credit()
    credits_menu.show_img_credit()

Solution

On this line:

        running, playing, credits_menu, options_menu = False, False, False, False

you set credits_menu to False

This overrides its earlier definition as a class



Answered By - Jiří Baum
Answer Checked By - Katrina (Python.Easybugfix Volunteer)

Related Posts

Post a Comment