Quantcast
Channel: Pixi.js Latest Topics
Viewing all articles
Browse latest Browse all 3978

What is the quickest way to find a sprite inside a container and work on it?

$
0
0

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?


Viewing all articles
Browse latest Browse all 3978

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>