scene2d - Flicker of ImageTextButton in libgdx -
i'm creating store stage in libgdx using scene2d.ui package. i'm seeing weird flicker when showing stage larger versions of buttons appear behind smaller buttons:
the larger background buttons flicker on , off, while front ones appear normal. background ones aren't clickable, front ones - again, appear normal.
here relevant code:
private void init(skin skin) { this.skin = skin; boytexture = new texture(gdx.files.internal("images/character.png")); cattexture = new texture(gdx.files.internal("images/character_cat_girl.png")); horntexture = new texture(gdx.files.internal("images/character_horn_girl.png")); pinktexture = new texture(gdx.files.internal("images/character_pink_girl.png")); queentexture = new texture(gdx.files.internal("images/character_queen_girl.png")); // set root table table = new table(); table.setfillparent(true); addactor(table); table.add(new label("characters: ", skin, "default")).padleft(10).colspan(2); table.row(); buttongroup charactergroup = new buttongroup(); charactergroup.setmaxcheckcount(1); button boybutton = createimagetextbutton("plain boy", boytexture); table.add(boybutton); button catbutton = createimagetextbutton("cat girl", cattexture); table.add(catbutton); table.row(); button hornbutton = createimagetextbutton("horn girl", horntexture); table.add(hornbutton); button pinkbutton = createimagetextbutton("pink girl", pinktexture); table.add(pinkbutton); table.row(); button queenbutton = createimagetextbutton("queen", queentexture); table.add(queenbutton).colspan(2); //addaction(actions.sequence(actions.alpha(1f), actions.fadein(1))); } private button createimagetextbutton(string label, texture texture) { imagetextbutton button = new imagetextbutton(label, skin, "default"); button.getimage().setdrawable(new spritedrawable(new sprite(texture))); return button; }
at first thought had transition actions, can see i've commented them out , it's still happening.
i thought problem imagetextbutton, changed createimagetextbutton
method return plain textbutton
. still has flicker buttons aren't enlarged in background - seem flicker on sides same size foreground ones.
here constructors, requested in comments below:
public store(skin skin) { super(); init(skin); } public store(viewport viewport, skin skin) { super(viewport); init(skin); } public store(viewport viewport, batch batch, skin skin) { super(viewport, batch); init(skin); }
i'm using last 1 when creating stage in maingame class.
public class maingame extends applicationadapter { public static final int min_width = 480; public static final int min_height = 800; public static spritebatch batch; public static gamestage game; public static store store; public static skin skin; public static viewport viewport; public static stage stage; @override public void create() { viewport = new extendviewport(min_width, min_height); batch = new spritebatch(); initskin(); game = new gamestage(viewport, batch, skin); store = new store(viewport, batch, skin); setstage(game); } ... @override public void render() { stage.act(gdx.graphics.getdeltatime()); stage.draw(); } @override public void resize(int width, int height) { viewport.update(width, height, true); } ... public static void setstage(stage stage) { maingame.stage = stage; gdx.input.setinputprocessor(stage); } }
Comments
Post a Comment