How to process resumes for libmdx image with pixmap texture

I have com.badlogic.gdx.scenes.scene2d.ui.Image which is built from Pixmap. Pixmap is only one pixel, because I use it to create an image that functions as a background that can fade in and out.

Pixmap pmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
pmap.setColor(1.0f, 1.0f, 1.0f, 1.0f);
pmap.drawPixel(0, 0);
bgImage = new Image(new Texture(pmap));
pmap.dispose();
bgImage.setSize(MyGame.VIRUAL_WIDTH, MyGame.VIRUAL_HEIGHT);
bgImage.getColor().a = 0.0f;
bgImage.addAction(Actions.sequence(Actions.fadeIn(1.0f),Actions.delay(3.0f),Actions.fadeOut(1.0f)));
stage.addActor(bgImage);

It works great, but I am worried that the game may be paused during action. I assume that the actions will continue after renewal, so I need to keep the same image, but the underlying Pixmap is not controlled and therefore must be recreated after renewal. It’s hard for me to figure out how to snap a texture / Pixmap to an image. Building the Pixmap itself is easy, but getting an existing image to use is a problem.

+3
source
2

Image setTexture. Image(Texture), :

this(new TextureRegionDrawable(new TextureRegion(texture)));

, - Image.setDrawable . - :

bgImage.setDrawable(new TextureRegionDrawable(new TextureRegion(new Texture(pmap))));

, , , TextureRegion ( pixmap Texture TextureRegion .

+2

:

Pixmap pixmap =...

TextureData texData = new PixmapTextureData(pixmap, Format.RGBA8888, false, false, true);
Texture texture = new Texture(texData);
Image image = new Image(texture);

PixmapTextureData "". .

, , , . http://www.badlogicgames.com/wordpress/?p=1513

+5

All Articles