Subject: intro to slick-AE
It seems that many people want to try out slick on android, and that all of the people who try run into trouble. This post is meant to outline:
1. How to setup a slick game to run on android
2. Issues with slick on android and their workarounds
I am not so brilliant that I figured out Slick-AE myself, most of this I learned from others on the forum. Thus, there are things I will likely forget in this outline, and I hope that if anyone comes across something I have left out, they will tell me so.
Part one: how to run a slick game on android
1. First off, you are going to need to install eclipse and the android plugin for eclipse. Instructions can be found here: http://developer.android.com/sdk/installing.html
2. Next, you will need to download the source for Slick, and Slick-AE (both located in https://bitbucket.org/kevglass/slick/downloads
). Slick-Android-Test is not required, but is extremely useful as an example of a working android program.
3. To get Slick-AE into a useable state, you will need to compile it into a jar. First, configure the Slick-AE build path to include Slick in your workspace, which should get rid of any errors Slick-AE has.
4. Next, run build.xml in Slick-AE. Once it is finished, refresh the workspace, and there should be a fully functional slick-ae.jar in the target folder.
5. In order to run your game on android, it will need both a normal java project (for running on a computer) and an android project (for running on android). Assuming you have a java project already, make a new Android project and add the java project to its build path.
6. Slick-AE is built off of the libgdx engine, so there are three jars and two folders that the android project will need to run your project, and they all need to be in a folder called “libs” in the android project folder. They are: the slick-ae.jar you just built, gdx.jar, gdx-backend-android.jar, a folder called armeabi, and another folder called armeabi-v7a. Make sure the jars are put on the build path (armeabi and armeabi-v7a should not be on the build path). All of these, except the slick-ae.jar should be taken from the Slick-AE project under the folder lib. There are newer versions of libgdx available, but at the time of this writing, Slick-AE needs to be tweaked in order to use them. This will be discussed further in sections two and three. For now, just use the stuff in the lib folder of Slick-AE.
7. Move all of the resources for the game into the assets folder in the android project (this should be automatically generated) they will be used as though the folder “assets” were not there. Also, you will need to copy defaultfont.fnt and defaultfont.png from the Slick-AE project into the assets folder of your android project.
8. Finally, there should be a single class in the source folder of the android project. You must change three things: make it extend SlickActivity instead of Activity, remove the line that says “setContentView(R.layout.main);”, and add the line “start(new YourGame(), 850, 480);” where YourGame is your game from the java project, 850 is the width of the screen, and 480 is the height of the screen.
9. Your android project is now ready to debug!
Part two: Troubleshooting
Out of memory errors occur a lot. Android has much less available memory than a computer, so all of the resources may not fit in the memory at once. Best to use small images or unload images once they are finished.
jpg files, 24 bit png files, and mod music files are not supported by libgdx. Best to convert them into 32bit png and other music formats
(thanks to Tobse: viewtopic.php?t=3389
Tiled maps sometimes have skewed sections. I don’t know a solution.
container.getGraphics().copyArea(Image,int,int); does not seem to work. I don’t know a solution, and any solution would need to be implemented with the knowledge that if the user suspends the app (by, say, going to the home screen), the grahic will be lost.
Restarts when screen is rotated or droid keyboard is deployed.
By default, when the screen is rotated the onCreate method is called again. The way you stop that is by adding the following lines in the manifest:
(thanks to Ciph3rzer0: viewtopic.php?t=3496
This is what I know so far. If I missed something, please let me know.