1
\$\begingroup\$

I'm using scene2d for the first time, and I can't get anything to draw EXCEPT the stage ui. Say I have my ui on top of my game screen:

uiStage.act():
batch.begin();
gameSprite.draw(batch); //does not show up
uiStage.draw();
batch.end();

How can I render my game, and then render my gui stage on top? Should I use a stage for both the game and the ui?

\$\endgroup\$
1
  • \$\begingroup\$ Anyone? This website is empty \$\endgroup\$ Commented Apr 10, 2014 at 11:56

1 Answer 1

2
\$\begingroup\$

You should render stuff consecutively. Mixing up the rendering of your batch and that of the stage is not the way to do it. Especially if to consider that I am almost convinced the batch you are showing in your code and that used by the stage are two different objects.

Change your code as follows:

batch.begin();
gameSprite.draw(batch);
batch.end();

uiStage.act();
uiStage.draw();

I also highly recommend that you watch dermetfan's (Robin S.) beginner tutorial on libGDX, he makes use of scene2d in his episodes and provides very nice explanation and illustration of how to work with it properly. Just watch them all, starting with this one Java Game Development (LibGDX) | Episode 1.

Hope this helps you.

\$\endgroup\$
1
  • \$\begingroup\$ Thanks but I have most of libgdx down by now \$\endgroup\$ Commented Apr 10, 2014 at 19:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .