Using collision with lists

I’m having trouble using collision with list items. Is my code wrong or is it a limitation of CoBlocks? The disabled code in this scene works but it would be much more efficient to use a list. https://cospac.es/9yUe

Thanks!

Hi @MBridges,

You were getting close to the solution! In order to set events on multiple items at once, you want to iterate through the list with the for each - block, and use a function with parameter to make sure that an event-handler is created for every checkpoint in the list.

Below you can find a remixable space with working code. Feel free to check it out to see how the CoBlock was adjusted to make it all work :slight_smile:

2 Likes

Thank you, Stefan! I knew there was a way!

1 Like

I would like to hide several mice, put them in one list and each time one of those mice in the list is clicked, a count (here: text) goes up one. I could do that individuall for each mouse, but that seems unnecessary. Can’t find the mistake, can you help?


Cheers

You are almost there! Instead of “mouse” and “Mäuse”, use the word “element”. In this way, you can click any mouse, in any order. I’ve used your code here, with cats. https://edu.cospaces.io/JQY-ZZL

Let me know if you have any questions! :slightly_smiling_face: Margo

Thank you so much!!! :star_struck:

You are most welcome! :grinning:

ghjgfhjgfjhgfjghfjghfjghfjghfjghfghfjghfjhgfjghfterwrfeda hello