I am making a Android game with LibGDX (using ADT eclipse bundle). How do I choose the default activity to launch when the user opens the app. I set the project up with the LibGDX setup GUI, and I can't find the main activity. I want a main menu to open before the game starts, is there something I should change in the manifest? Thanks in advance.
If you are using LibGDX, you need to forego the concept of Activities and Views, since your entire game will now just be a single Activity. To have a main menu when you game starts up doesn't switch the Activity, but just presents a different set of objects to be rendered to the same Activity.
The easiest way to accomplish this would be to do the following. You should have a .java file in your -core project named after your game name. It would be a class extending
ApplicationListener. Now, change it to extend
Game instead, which should be in the package
com.badlogic.gdx. If you look at the logic of the
Game class, you will see it has a
setScreen function. Once a
Screen has been set, it simply passes all the method calls like
resize() to a given screen.
Thus, to have different screens, just create a new class that extends
com.badlogic.gdx.Screen. You can do this for any number of screens you need (e.g., MainMenuScreen, GameScreen). Whenever you need to switch screens (e.g., going from Main Menu -> Game), you can just call the
setScreen function from your game.
The reason why you should take this approach, and not mess with the manifest.xml and adding additional activities, is because in this way your game is cross-platform. Your main menu will not just be specific to the Android build, and can be used across desktop, ios, and html too.