Say I have several animal objects(cat, dog, goat etc....). On click of sprite i want to play respective sound of animals. Now to achieve this i have to detect click event on each sprite and perform corresponding action. Can I some how generalise this? May be using family. So If I click on any member of family, It should play respective sound stored in instance variable of the respective sprite. for e.g. All the sprite will have instance variable name 'sound' and they will store specific sound name in it. Like Dog will store 'dog_sound' and cat will store 'cat_sound'. So probably this way I have to write only one event - action pair.
Animal -> Onclick() -> play Animal.sound
Is it possible? Or any other way I can achieve the same?