Planets App (Android/Scene2D/Lerp)

Cheng Xi Tsou
3 min readAug 13, 2018

With the camera lerp effect on hand, I wanted to make use of this in a program, so I came up with an idea of a simple app that would give some basic info on the planets of the solar system. The virtual world would basically be a large texture of universe background with planets scattered across the map. When the user presses a button, the camera would be directed to the planet with the camera lerp effect.

This was the final result. For the font, I used the quantum-horizon skin from https://github.com/czyzby/gdx-skins. I used Scene2D for the HUD, with lines of labels pasted on the left and a column of TextButtons to the right. Overall, the program was simple but making this had taught me much more about the things Scene2D can achieve, one of them being Actions. Here is a short gif of the lerp and animation in action:

List of classes:

Overall, the most challenging aspect of this app was definitely the Actions of the actor. At first, I tried to use MoveToAction and ColorAction in order to replicate the fade in effect (although I think there is a method for fade-ins), the Actions were sequential so I had to make a series of Actions using Parallel Actions. The one problem I had with this was somehow I couldn’t get the action to restart since I wanted to play the action whenever a planet was being “loaded in”, so the effect only happened for the first time you pressed the button.

I’ve also managed to port the program to Android! I had trouble getting the SDK setup since the Android folder wouldn’t show up when selecting the file, but it worked if I had manually typed in the folder path. Some improvements I could make to the program is dealing with screen ratios. Although it looked perfect on desktop, the placements and measurement of Scene2D were catered to 800×480, which was the default I had set. When I loaded it up on my phone, the button ratios were off and it looked kind of awkward.

Some improvements I could make to this program is a more efficient way of making the camera lerp effect. I had used a HUGE 10 by 10 rectangle of a universe texture and space the planets far enough so the camera lerp effect can be seen clearly. Also, I had spaced the planets out 2 rows by 4 columns, so after Mars the camera would lerp to the top left of the screen which kinda didn’t make sense if you look at the solar system. Some things I could’ve added to make it better are space music, some kind of menu screen, and more info about each planet as the program looked a bit bland.

Originally published at http://noviceprogramming667661022.wordpress.com on August 13, 2018.

--

--