Guss
Guss

Reputation: 21

Starling SetChildIndex performance issue

I have a Problem with the performance of Sprite.setChildIndex. I have to display a world that consists of many small Images. (about 10.000)

To have the best performance, i use a image pool and all images are allways in the display List of one Sprite, so I do not have to add and remove the images.

If I want to display a new Region of the world I only have to move the images to the new position. This process is really fast and takes about 6 ms.

But the problem is, that the order of the images in the display List is important to me. Because of that i have to use setChildIndex to rearrange the images. The process of setting the images to the correct position in the display List (setChildIndex) has a deep impact to the performance and so I need about 60 ms to display a new Region. Do you have a idea how to optimize the process or is there a alternative to the setChildIndex method?

Upvotes: 2

Views: 292

Answers (1)

Nick Pedalino
Nick Pedalino

Reputation: 31

You could give each Region of the world its own container, and put that container in a world container. This way, you can setChildIndex or swapChildren with a grouping of, say, 500 images rather than 10,000. And, if you want to load up a new Region, you can just setChildIndex on the entire Region container (within the world container). This will optimize map loading, rather than having to pay attention to all 10,000 sprites.

Upvotes: 0

Related Questions