Image
is a subclass of Actor
. The main difference is, that Image
has a Drawable
inside. This Drawable
gets drawn if you call stage.draw()
, which calls the draw()
of Image
. Instead of changing Image
you can change the Drawable
by using setDrawable(Drawable param);
.
What is a Drawable
? It is any class, which implements the Drawable
interface, for example the TextureRegionDrawable
. If you are using TextureRegion
s you can use this constructor: TextureRegionDrawable(TextureRegion region);
. Maybe it would be better to store your background images in a Drawable
Array so you don't have to call a construcor each time you set a new Drawable
. Example code:
TextureRegionDrawable[] images = new TextureRegionDrawable[12];
for (int i = 0; i<12; i++) {
images[i] = new TextureRegionDrawable(Assets.instance.textureRegions[i]);
}
Then in your render:
if(changeBackground) {
counter -= delta;
if (counter < 0) {
counter = refreshtime
background.setDrawable(images[(int)(Math.random()*12)]);
}
}
This should work