This is a guest post by Alexander Fröhlich. Alexander is a freelance developer and is supporting ANDLABS at its libgdx-based development.
libgdx is an open source, Open GL based, cross platform game development framework. It’s supporting Web, Desktop, Android and iOS. This step by step introduction will teach you how to get started with the initial setup and your very first hello world in libgdx.
1 Prerequisites
- Get the Android SDK and set up a functional eclipse environment
- Go to libgdx and checkout the general “libgdx-Wiki-Guide“
- Go to “Project Setup” where you will find a download link to
- “Setup the application” – either start it from command line “java -jar gdx-setup-ui.jar” or just double-click on the downloaded file.
2 Setup a new libgdx project
- Choose “CREATE” in order to create a new project and enter the following setup screen
- ConfigurationTab lets you set names for projekt/package/mainGameClass and the destination folder
- Library Selection lets you download all required libraries (libgdx as the core libs are always required)
- Overview gives you an outlook on which projects will be created
- Generation checks for a valid setup (green colored) and when read you can open the generation screen (launch window coming up)
- Launch displays the log output while creating the project. Here just click “Launch” to finalize your setup and create all chosen libgdx projects
3 Import libgdx projects into eclipse
Now we need to import these project into eclipse (other IDE provide similar options -> wiki)
NOTE: iOS projects have to be imported with XCode only (apple-mac) -> wiki
4 Project launch configurations
You now should see four projects… YourGameName, YourGameName-Android, YourGameName-Desktop and YourGameName-html within eclipse’s package explorer. The first one being the core source project holding all your game logic and the latter being launcher projects holding only one starter class.
DESKTOP
Go to your newly imported desktop project and launch its Main.java (run as java application)
This should bring up this demo screen. As you can see libgdx already provides you with a small hello world application.
ANDROID
Your eclipse android project should have been marked with a red x (eclipse way of telling you something is wrong with your setup).
Go to project properties (ALT-ENTER) and select your available Android-SDK-version..
NOTE: on versions prior to 4.0 you might have to remove the line
android:configChanges=”keyboard|keyboardHidden|orientation|screenSize”>
from your AndroidManifest.xml as this option being unsupported
After this, refresh both your core source project and your android project and rebuild both projects.
Now right-click on your Android project and choose “Run as Android Application”.
A dialogue will come up showing all connected devices and you may either want to push it on one of these or use the emulator (which will automatically start without any registered devices).
Make a choice and the game will be transfered on started on your device.
HTML5
A red cross over your project might mean that you have to install GWT.
After having GWT set up correctly, right-click on your HTML5-project and choose “Run as Web Application”.
Double click on the provided link ( e.g. http://127.0.0.1:8888/index.html?gwt.codesvr=127.0.0.1:9997)
A browser window will show up maybe requiring to install a GWT Developer Plugin
(Development Mode requires the Google Web Toolkit Developer Plugin).
If so, do restart the browser and you should see the libgdx logo screen.
Now you are up and ready to start building your own libgdx-based game. If you have any questions, please post them in the comments.
Update [2013-09-13], important links:
Starter Tutorial:
http://bitowl.de/day1/
Libgdx Wiki
https://code.google.com/p/libgdx-users/wiki/AAATopPaaage
Forum: (most problems have been solved already.. just learn to query it wisely like the web :-)
http://www.badlogicgames.com/forum/