You could use one physics group per fruit and let each fruit only collide with the walls and its own kind. You achieve this by setting the group and mask fields of each collection object. You can check which group you collide with by checking message.other_group
.
The other option is to do what you are doing in your code and check which sprite animation you have and compare it to the list of all fruits. BUT I think you have a bug in your code, the go.get(url, "animation")
will return a hash, not a string, which means that you should store hashed strings in your fruit_list
.
By the way, here’s a similar game made in Defold. I’m sure @schlista can give you advice as well.