0
votes

I have a lot of stars (an array of sprites) that I draw on my background. But when the user starts another level it may need to get those stars' Texture from another Atlas. just before level restart I change all star sprite textures with setRegion, but sometimes 2 or 3 out of 500 stars don't change the texture properly and are drawn on the screen like a black rectangle:

for(int i = 0; i < stars.size() - 1; i++)
{
    stars.get(i).setRegion(another_Atlas.findRegion("star_type1"));
}

How can I make sure all star sprite textures are changed properly?

1
Did you bind the new atlas before trying to use it?rbennett485
How do I bind it? I just load it from the AssetManager with the AssetManager.load and AssetManager.get methods.gogonapel
Have a look here, in particular the part at the toprbennett485
Thank you! It worked now! Put it as an answer, I'll accept it!gogonapel

1 Answers

1
votes

Make sure you have bound your texture before you try to use it, by calling GLTexture.bind() (more on this here)