Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/andengine/forums/includes/utf/utf_tools.php on line 1804
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1804)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1804)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1804)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/andengine/forums/includes/utf/utf_tools.php on line 1804

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/andengine/forums/includes/utf/utf_tools.php on line 1804

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/andengine/forums/includes/utf/utf_tools.php on line 1804

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/andengine/forums/includes/utf/utf_tools.php on line 1804

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/andengine/forums/includes/utf/utf_tools.php on line 1804

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/andengine/forums/includes/utf/utf_tools.php on line 1804

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/andengine/forums/includes/utf/utf_tools.php on line 1804

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/andengine/forums/includes/utf/utf_tools.php on line 1804

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/andengine/forums/includes/utf/utf_tools.php on line 1804

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/andengine/forums/includes/utf/utf_tools.php on line 1804

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/andengine/forums/includes/utf/utf_tools.php on line 1804
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4363: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1804)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1804)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1804)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4367: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1804)
AndEngine - Forums • Eclipse, AndEngine and HelloWorld!!! : Tutorials

Eclipse, AndEngine and HelloWorld!!!

  ... tutorials on how to use AndEngine.

Eclipse, AndEngine and HelloWorld!!!

Postby Mimminito » Mon Aug 16, 2010 6:26 pm

It seems a few people who come here are a little confused as to how to get started with AndEngine, Eclipse, and even Android/Java in general. So I thought I would post this up for people to get started with.

First off, check out the following topic by Nicolas. Its about getting started with AndEngine and how to download the Engine:
http://www.andengine.org/forums/tutorials/getting-started-with-andengine-t11.html

Once you have checked that out, and you are still a little unsure about stuff, check the tips below.

Tip 1 - Eclipse
Eclipse is the IDE of choice for Android development. So it makes sense to use Google's recommended IDE, which also comes with a Plugin, allowing you to easily setup Android Development, your Virtual Android Devices/Emulators, and much more.
You can download Eclipse from the following location:
http://www.eclipse.org/downloads/

Once you have that downloaded, install it, and then check the following guide which will help you with setting up your environment:
http://developer.android.com/sdk/installing.html

Now you should be ready to go with some Android Development! So onto Tip 2.

Tip 2 - Getting AndEngine
Nicolas has made a smart choice with the way he distributes AndEngine. He uses Mercurial, which is a Version Control System for projects. It can be directly used with Google Code, and thats a massive plus!! It also has a Plugin for use within Eclipse, which you can download/setup by following the guide below:
http://www.javaforge.com/project/HGE

Once you have this installed, its time to download the AndEngine examples. This is where you should spend a good few hours looking through all of the Examples, familiarizing yourself with the structure of AndEngine and how you would go about accomplishing various tasks.
To download the AndEngine Examples, following these steps:

1. File -> New Project
2. Select the Clone Existing Mercurial Repository under the Mercurial folder
3. In the URL field, copy and paste the following link:
https://andengineexamples.googlecode.com/hg/
4. Optional - If you want to change the Local Projects Name, enter your preferred name in the Clone Directory Name field.
5. Press Next. This should then be shown a screen with what will be downloaded.
6. Press Next and then Finish to pull the AndEngineExamples down.

Well done, you now have the AndEngine Examples on your system!
Note: If you cannot see the AndEngine Examples Project within your Eclipse Worksapce, then try to import the project from your workspace. You can do this by selecting File -> Import -> Existing Projects Into Workspace.

Right, so we now have the AndEngine Examples on our system. So go away, and like I said before, look through them all. See what they all do, build them and try them on your Phone or Emulator. Once you are done, then move onto the next tip.

Tip 3 - Hello World
So, now that we have everything setup, and that we have had a look at the Examples for AndEngine, you are going to want to try and code something yourself. Well, your in luck. This tip will show you how to create your own Project, and display a simple Sprite on the Screen.

So, first up, create a New Project! Go to File -> New, and the select Android Project from the Android folder. Choose a name for your Project, such as "HelloWorld".

Now this is done, we need to import the AndEngine Library into out project so that we can actually use it! Follow these steps:
1. Right Click on your Projects Name
2. Select New -> Folder and create a folder called lib
3. Open up your AndEngine Examples Project, and go to the lib folder.
4. Copy the andengine.jar
5. Past the andengine.jar into your newly created lib folder.

Now you need to add the Library to your Projects Build Path. This is very easy, so follow these steps:
1. Open your lib folder
2. Right Click on the andengine.jar
3. Select Build Path -> Add To Build Path

You now have the AndEngine Library setup in your project! So lets get down to some code

Open up the default Activity for your Project, which should be called HelloWorld.java if you named your project like I said. Now, DELETE EVERYTHING from this file, EXCEPT the package line at the top of the file.
Once you have done this, copy and paste the following code into your file:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class HelloWorld extends BaseGameActivity {
  2.         // ===========================================================
  3.         // Constants
  4.         // ===========================================================
  5.  
  6.         private static final int CAMERA_WIDTH = 720;
  7.         private static final int CAMERA_HEIGHT = 480;
  8.  
  9.         // ===========================================================
  10.         // Fields
  11.         // ===========================================================
  12.  
  13.         private Camera mCamera;
  14.  
  15.         // ===========================================================
  16.         // Constructors
  17.         // ===========================================================
  18.  
  19.         // ===========================================================
  20.         // Getter & Setter
  21.         // ===========================================================
  22.  
  23.         // ===========================================================
  24.         // Methods for/from SuperClass/Interfaces
  25.         // ===========================================================
  26.  
  27.         @Override
  28.         public Engine onLoadEngine() {
  29.                 this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
  30.                 return new Engine(new EngineOptions(true, ScreenOrientation.LANDSCAPE, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), this.mCamera));
  31.         }
  32.  
  33.         @Override
  34.         public void onLoadResources() {
  35.         }
  36.  
  37.         @Override
  38.         public Scene onLoadScene() {
  39.                 this.mEngine.registerUpdateHandler(new FPSLogger());
  40.  
  41.                 final Scene scene = new Scene(1);
  42.                 scene.setBackground(new ColorBackground(0, 0, 0.8784f));
  43.  
  44.                 return scene;
  45.         }
  46.  
  47.         @Override
  48.         public void onLoadComplete() {
  49.  
  50.         }
  51.  
  52.         // ===========================================================
  53.         // Methods
  54.         // ===========================================================
  55.  
  56.         // ===========================================================
  57.         // Inner and Anonymous Classes
  58.         // ===========================================================
  59. }
  60.  
Parsed in 0.013 seconds, using GeSHi 1.0.8.4


Then press Ctrl+Shift+O and your project should sort all of the Import Statements out for you.

Before you build, make sure you add the following line into youe AndroidManifest.xml file:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <uses-permission android:name="android.permission.WAKE_LOCK"/>
Parsed in 0.000 seconds, using GeSHi 1.0.8.4

This allows AndEngine to run and use the permissions it needs.

Now, try to build and run this. If it builds properly, it should run on your Phone/Emulator and display a bluey background. If so, well done you have written your first AndEngine Project! Its as simple as that. If you want do display a Sprite, check out the following SpriteExample which will display a Sprite on your Screen.
Sprite Example

To get use to Touch, check out the following examples, and try to add them to your Project:
Sprite Remove Example
Touch Drag Example

Thats the end of this tutorial. If you feel more needs to be added, such as how to do something within AndEngine, let me know and ill add it in.

Otherwise see you next time!
Last edited by Mimminito on Mon Aug 16, 2010 7:26 pm, edited 2 times in total.
---------------------------------------
Adam Goodchild
Your AndEngine Forum Moderator!
My Tutorials List
http://www.adam-goodchild.co.uk
---------------------------------------
Mimminito
 
Posts: 360
Joined: Wed Jul 21, 2010 3:08 pm
Location: Chelsmford, UK

Re: Eclipse, AndEngine and HelloWorld!!!

Postby russick89 » Mon Aug 16, 2010 7:21 pm

Very helpful tutorial!!! THANKYOU!!!
Last edited by russick89 on Mon Aug 16, 2010 7:24 pm, edited 1 time in total.
russick89
 
Posts: 11
Joined: Mon Aug 16, 2010 7:17 pm

Re: Eclipse, AndEngine and HelloWorld!!!

Postby Mimminito » Mon Aug 16, 2010 7:24 pm

Very strange. The Camera class takes in them parameters... can you post the actual error, or is it just a warning?
---------------------------------------
Adam Goodchild
Your AndEngine Forum Moderator!
My Tutorials List
http://www.adam-goodchild.co.uk
---------------------------------------
Mimminito
 
Posts: 360
Joined: Wed Jul 21, 2010 3:08 pm
Location: Chelsmford, UK

Re: Eclipse, AndEngine and HelloWorld!!!

Postby russick89 » Mon Aug 16, 2010 7:26 pm

Mimminito wrote:Very strange. The Camera class takes in them parameters... can you post the actual error, or is it just a warning?


It was my mistake, i imported the wrong camera class :lol:
I tried to edit my post before anyone read it to avoid embarrassment
russick89
 
Posts: 11
Joined: Mon Aug 16, 2010 7:17 pm

Re: Eclipse, AndEngine and HelloWorld!!!

Postby GalaxyKnight » Mon Aug 16, 2010 7:31 pm

Respect.
Many thanks for that.
Thats really what i need. I faild with the mercurial plugin. But now i have this wounderfull tutorial.
Thanks, thanks...
Greets
Mikel

##edit

So i tested it so far.
Everything works with the import but:
3 errors left. im so cunfused. Tell me if im to stressy.
Image

Uploaded with ImageShack.us
Last edited by GalaxyKnight on Mon Aug 16, 2010 7:46 pm, edited 1 time in total.
GalaxyKnight
 
Posts: 10
Joined: Sat Aug 14, 2010 10:56 am

Re: Eclipse, AndEngine and HelloWorld!!!

Postby Mimminito » Mon Aug 16, 2010 7:38 pm

Haha no problem. We all learn from mistakes. Just check that you import the correct statements from now on when it gives you a list.
---------------------------------------
Adam Goodchild
Your AndEngine Forum Moderator!
My Tutorials List
http://www.adam-goodchild.co.uk
---------------------------------------
Mimminito
 
Posts: 360
Joined: Wed Jul 21, 2010 3:08 pm
Location: Chelsmford, UK

Re: Eclipse, AndEngine and HelloWorld!!!

Postby GalaxyKnight » Mon Aug 16, 2010 8:11 pm

Sorry.
A new project. New luck.
And yes. It works now. Thank you.
GalaxyKnight
 
Posts: 10
Joined: Sat Aug 14, 2010 10:56 am

Re: Eclipse, AndEngine and HelloWorld!!!

Postby Nicolas Gramlich » Fri Aug 20, 2010 10:03 pm

Thanks a lot for all the time you spend in making the tutorials :!:
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Re: Eclipse, AndEngine and HelloWorld!!!

Postby wrothgar » Thu Sep 16, 2010 6:06 pm

Hello, let me first say thank you for the work on the engine and the tutorials. I have been playing around trying to create a game in android and I would like to move the idea to OpenGL. So please excuse me if my questions seem simplistic, but while I am experienced with Java I am new to game development and OpenGL.

After completing your tutorial I wanted to take the race car game from the engine examples and try to make it run as a new project. Once running I was going to start altering things to get use to working in the platform (add graphics, change behaviors, etc).

Well I created a new project (following the hello world example), copied in the andengine.jar and added it to the buildpath, added in the graphics, and then copied the code from RacerGameActivity.java. Right away I saw a number of link errors where it appears to be looking for the "andenginephysicsbox2dextension.jar" library. So I added that to the lib folded and added it to the build path and the project was able to build cleanly. But, when I try to run the program in the emulator or my cell it crashes. The error is:

09-16 15:43:20.057: ERROR/AndroidRuntime(964): Uncaught handler: thread main exiting due to uncaught exception
09-16 15:43:20.087: ERROR/AndroidRuntime(964): java.lang.ExceptionInInitializerError
09-16 15:43:20.087: ERROR/AndroidRuntime(964): at com.jking.racetest.Main.onLoadScene(Main.java:133)
.
.
.
09-16 15:43:20.087: ERROR/AndroidRuntime(964): Caused by: java.lang.UnsatisfiedLinkError: Library andenginephysicsbox2dextension not found
09-16 15:43:20.087: ERROR/AndroidRuntime(964): at java.lang.Runtime.loadLibrary(Runtime.java:489)
09-16 15:43:20.087: ERROR/AndroidRuntime(964): at java.lang.System.loadLibrary(System.java:557)
09-16 15:43:20.087: ERROR/AndroidRuntime(964): at org.anddev.andengine.extension.physics.box2d.PhysicsWorld.<clinit>(PhysicsWorld.java:30)

I am sure that this is due to some step that I missed but I cannot figure it out for the life of me. Can anyone offer any help?

Thanks!
wrothgar
 
Posts: 19
Joined: Thu Sep 16, 2010 5:45 pm

Re: Eclipse, AndEngine and HelloWorld!!!

Postby wrothgar » Thu Sep 16, 2010 10:56 pm

Update: I found my problem.

The problem was that I forget (actually didn't know) to add the .so file in the libs/armeabi directory. Once I did that it seems to be running fine. I found the answer in the Physics 2d forum.

I am very excited to keep playing with this engine and seeing what I can do and maybe get my game idea off the ground.

Thanks!
wrothgar
 
Posts: 19
Joined: Thu Sep 16, 2010 5:45 pm

Next

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 9 guests