Something happening here as it does not print HOVERING
when the button is over the self.rect
? The pos
prints fine, but nothing showing and no response to clicks.
class Button():#======================================================================================
def __init__(self,x,y,image):
self.image = image
self.rect = self.image.get_rect()
self.rect.x = x
self.rect.y = y
self.clicked = False
def draw(self):
action = False
#get mouse position
pos = pygame.mouse.get_pos()
print(pos)
#check mouse over and clicked conditions
if self.rect.collidepoint(pos):
print('HOVERING')
if pygame.mouse.get_pressed()[0] == 1 and self.clicked == False:
print('CLICKED')
action = True
self.clicked = True
if pygame.mouse.get_pressed()[0] == 0:
self.clicked = False
#draw button
screen.blit(self.image,self.rect)