Making a button for a menu screen. I had to adapt from an example online so I could use a custom image to work as a button. Rather than using,
play_button = pygame.Rect(50,100,200,50)
Heres what I have so far,
def main_menu():
while True:
#menu background
menu_background = pygame.image.load('game graphics/menu.png')
menu_background = pygame.transform.scale(menu_background, (screen_w,screen_h)).convert()
screen.blit(menu_background,(0,0))
#menu buttons
mx, my = pygame.mouse.get_pos()
play_button = pygame.image.load('game graphics/play_button.png').convert_alpha()
play_button = pygame.transform.scale(play_button, (400,300))
# play_button = pygame.Rect(50,100,200,50)
screen.blit(play_button,(-50,200))
if play_button.collidepoint((mx,my)):
if click:
game()
The error im getting is,
AttributeError: 'pygame.Surface' object has no attribute 'collidepoint'
All I want to do is have the image I have selected used as a button. What am I doing wrong?