Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Hello I want to combine between android UI and libGDX. I want to have half of my screen with libgdx engine (animated sprite) and the other half of the screen with android UI buttons. Does anybody know how to do it?

share|improve this question
    
I don't think that is possible. When you initialize an opengl context it kinda puts the screen in 'full screen' mode. I might be wrong though. –  petervaz Jun 18 '13 at 15:30
add comment

2 Answers 2

Libgdx has a great UI package called scene2d. It is specially written for UIs, but can be used for other things also.

https://code.google.com/p/libgdx/wiki/scene2dui

What you will want to do is create a UI stage. During your game loop call stage.draw() after you draw your game so it renders over the top of your game. If you just want to use the UI to receive input then just use Gdx.input.setInputProcessor(...) to set the UI stage as the input processor. If you want the game and the stage to receive input you will need to use an InputMultiplexer.

You add widgets (widgets being things like tables, buttons, and more) to the stage. And then add change listeners to the particular widgets to help control your game.

share|improve this answer
1  
There is also a skin that makes it look very close to native Android UI. badlogicgames.com/forum/viewtopic.php?f=22&t=8533 –  Vincenzo Jun 18 '13 at 15:31
add comment

Nothing special, it just works. Libgdx view is just a wrapper around an ordinary OpenGL view, you can use it with any layout (including a LinearLayout split in half).

The autogenerated code has an initialize call. This call creates the Libgdx view and displays it using full screen.

If you remove the call, you can instead use initializeForView. This method creates and returns the Libgdx view, but does not display it (nor switches to full screen), so you can place it in any layout you want.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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