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\$
  • \$\begingroup\$ Anyone? This website is empty \$\endgroup\$ – user3466304 Apr 10 '14 at 11:56
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.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thanks but I have most of libgdx down by now \$\endgroup\$ – user3466304 Apr 10 '14 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.