Home Classroom Android Development Lets try Android Game Development with AndEngine

Lets try Android Game Development with AndEngine

Hi Guys, this time I am back with some Android Game Development. I got this idea after, the popular game Flappy Bird. Hope all may have tried that game…!
Ok, so I wanted to develop a game and I did some researches and found out that there are a lot of Game engines out there. Some of them are COCOS2D, AndEngine, libGDX and many others. In this article I’ll guild you using AndEngine which is a bit easier one. In future I’ll write on libGDX.

Assumption : I assume that you guys know how to install eclipse development environment, configure java path and install Android plugin to eclipse. This post does not cover all those basic steps.

Advise : As this is a kind of a crash course, its advisable to create files the same name as I use(But it is not mandatory).

Expected Outcome : You will be able to create some lines using the AndEngine

Step 1
Download the Source(library) for the AndEngine using this link and extract

https://github.com/nicolasgramlich/AndEngine

Step 2
Create a new project and when creating select ‘Android Project from Existing Code’ and in it select the folder that we extracted in the Step1.
existing code

This is a library project. Actually this library is the ANDENGINE.
libraryproject

You can check it by right clicking on the project we created now and going to the Android tab. You can see the ‘Is Library’ check box ticked.

Step 3
Now create a new Android project and un tick the create activity. Because we are going to create AndEngine activity using the library project we created above.
createactivity

Step 4
Now you have a project with empty src folder. Right click on that folder and create a new package when naming the package use the package name available in that project ManifestFile
packagename

In my case package name is ‘”com.batz.andengsample”‘

Step 4
Now in side the empty package Download or copy the code and create LineEample.java activity using this LineExample Source Code.

You will get some errors, but don’t worry we will fix it in the next step.

Step 5
So now in your project, right click and go to Android tab and there in the below section(library section), click on the add button and select the AndEngine project and press ok. And then press Apply.
add library

Now all the errors may have gone. Some times you will have errors on the package name, if you have used your own name. So for that, click on the package name that shows as error, click ctrl key +1 key , which will bring suggestion to create a package name according to yours, and click on it to create it. And hopefully all the bugs will be fixed.

Step 6
Before going for the app launch, we have to do one more important thing, we have to specify the activity we created now in the manifest file as a launcher

So go to the manifest file and add these lines between the application tags

<activity
android:name=”.LineExample”>
<intent-filter>
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
manifest

LineExample is the name I gave for the activity we created, so in your one don’t forget to change that

Step 7
Now you are ready to run the app. So while you are in the the activity try running the app. it should bring a screen where you will see lots of random lines.

Step 8(For people getting error saying cannot find andengine.apk)
For some people the AndEngine folder is not getting added as library on the time of building the app. So at that point what you can do is copy the andengine.jar file from the AndEngine project libs folder and copy it into your projects’s libs folder. And right click on the newly added andengine.jar file and click on ‘Add to Build Path’ option. This is how the project structure looks after I added the jar to my project from the AndEngine project in the Step8

projectstructure

AndEngine Resources : http://www.andengine.org/

For people who got more time , for people who needs more detailed instruction on the same project guild please watch this tutorial video
Development Reference : http://www.youtube.com/watch?v=Q0kjiIH6u-M

Thank You
-Batz-

Reference:  – http://pathofacoder.com/2014/03/04/lets-try-android-game-development-with-andengine/

Comments

comments

NO COMMENTS

Leave a Reply