Closed phanxgames closed 5 years ago
Thanks a lot for the suggestion! What would you say to this variation:
/** Removes all regions with names that start with the given prefix.
* If no arguments are given, all regions will be removed. */
public function removeRegions(prefix:String=""):void
{
for (var name:String in _subTextures)
{
if (prefix == "" || name.indexOf(prefix) == 0)
removeRegion(name);
}
}
Should be (almost) as fast, but can be used for selective removal, too. Somewhat similar to DisplayObjectContainer.removeChildren()
.
If you like that, I can add that right away.
Love it. Thanks, Daniel.
Done! :smile:
Again, thanks for bringing it up!
I have a need to reuse a TextureAtlas between levels and I wanted to remove all regions efficiently. I was using getNames() followed by an iteration calling removeRegion(), but getNames() uses a sort and didn't seem efficient.
So I was wondering if a function such as the following could be added to the TextureAtlas class:
Thank you for your input and feedback on this idea.