My problem step-by-step:
1)I have 0 images on the screen.
2) I create 1st texture and put in on the screen. There is my code to create texture:
fun getPlanetTexture(planetDiameter: Float): Texture {
val planetImage = FileSystem.getPlanetBodyFor(planet)
if (!planetImage.exists()) {
val planetBitmap = getPlanetBitmap(planetDiameter)
FileSystem.savePlanetBody(planet, planetBitmap)
}
val textureFileHandle = AbsoluteFileHandleResolver().resolve(planetImage.toString())
return Texture(textureFileHandle)
}
3) Texture appears on the screen, but if draws just like black rectangle.
4) I save the state of my app to save my models in prefs to get same files and textures enxt time I open the application.
5) I clsoe the application
6) I open the applciation
7) TA-DA! My texture is drawing correctly (it is texture of beautiful planet)
8) I add another texture to the screen.
9) My new texture and old texture too becames black rectangles!
What should I do to avoid black rectangles and always get correctly drawing textures?
This is my code I use to draw texture
override fun draw(sb: SpriteBatch, sr: ShapeRenderer) {
val x = model.x * bounds.x
val y = model.y * bounds.y
sb.draw(body, x - body.width / 2, y - body.height / 2)
}