I'm new in pygame, right now I'm working with sprites. My question is how do I detect if the sprite has been clicked? I want to do something when the sprite was clicked as if it were a button.
Thank you.
[Edited]
Thank you, Stephen. In addition is there a way to know who is the sprite that was clicked? Here is sample code:
boxes = pygame.sprite.Group()
for color, location in [([255, 0, 0], [0, 0]),
([0, 255, 0], [60, 60]),
([0, 0, 255], [120, 120])]:
boxes.add(UpDownBox(color, location)
For example I click the sprite in location [0,0], the program should print its colour or its location.
Thanks again.