In my game I have a lot of foods spread on the map and when my player moves around it should be able to see some of the foods and can't see the others. But every time I update my player's position I have to look for the index of the sprites representing foods around my player based on food id. I am using findIndex at the moment. It returns the index of the sprite of the food I need to add or delete and use
container.children[index]
to get the sprite. but this could be very expensive if I have thousands of foods. Is there any smarter way to do this?