Hi, I’m learning to build games on android platform. I’ve chosen libgdx to make my work easier. I’ve chosen libgdx with after a little bit of comparison. I won’t say that libgdx is superior to others, I just thought it is good to start with. Choice might vary with the kind of application you want to develop. I would say, when your are starting new, just chose the one with good amount of documentation and sample games. I’ve started trying out and faced few silly problems upon which I’ve wasted considerable amount of time. I just thought such mistakes might be most common to beginners, so I decided to post them regularly. I’d be more than happy to know if my post helped anyone save time 🙂
- Camera Position
- Initial Configuration for each platform
I’ve drawn few shapes using ShapeRenderer class. I’ve executed the application, but all I could see was just a blank screen. If you see a blank screen, there is a very high probability that you have not configured camera properly. By default orthographic camera is positioned at (0,0,0) and default viewport will show you a square of size 2*2 with centre at (0,0,0). But the view area will be shown as rectangle as viewport is wider than a square, so to fill up the area, image is stretched. Spritebatch has an internal camera, so to synchronize with our camera we just have to sync their projection matrices. (resources 1,2)
Initial Configuration for each platform:
- For Desktop Application: Configure Main.java or the class which you have configured to run. You can modify title, dimensions of java application and core class to run.
- For Android Application: Configure MainActivity.java to alter the core class to run. To change the name of your application, you have to edit the string in res/values/strings.xml which is used in AndroidManifest.xml file.