Getting started with AndEngine ...

  ... tutorials on how to use AndEngine.

Re: Getting started with AndEngine ...

Postby joshua.niland » Wed Oct 06, 2010 12:59 pm

Nicolas,

Many thanks on this fantastic AndEngine that you have constructed and provided for the community. I just ran though this tutorial on Win7 / Eclipse (helios) and it worked a treat.

I am looking forward to getting stuck into everything this engine has to offer!

Regards,
Joshua Niland
joshua.niland
 
Posts: 5
Joined: Tue Oct 05, 2010 2:12 pm
Location: Sydney, Australia

Re: Getting started with AndEngine ...

Postby sambocrockett » Fri Oct 08, 2010 2:38 am

I just tried to do the first tutorial with the box in the middle of the screen but even though i have no errors the emulator just wont open the app. I tried to move it onto my G1 to see if maybe the emulator just couldnt handle it but i get the same force closed message

The application andengine test (process andengine.test) has stopped unexpectedly. Please try again.

I know this is a simple tutorial so Im hoping some one would be kind enough to have a simple answer.....please :)
sambocrockett
 
Posts: 8
Joined: Thu Sep 23, 2010 9:08 am

Re: Getting started with AndEngine ...

Postby soshimo » Fri Oct 08, 2010 11:53 pm

sambocrockett wrote:The application andengine test (process andengine.test) has stopped unexpectedly. Please try again.



A couple of things to help troubleshoot your issues:

Are you also receiving this error on the emulator?
What is in your console window and log window when the emulator fails to load?
Can you post code so we can better help you troubleshoot?
soshimo
 
Posts: 11
Joined: Thu Sep 09, 2010 6:50 am

Re: Getting started with AndEngine ...

Postby sambocrockett » Sat Oct 09, 2010 10:00 am

Yes I am getting that message inside the emulator with no errors in the console at all. I figured that there was a chance that the andengine was to much for the emulator on my computer because in the past I have made some simple crude apps that didnt work inside the emulator but actually worked fine once I put them on a device ( an HTC G1 ) but I even tried it out on the device and got the same error. I just used the same code from the first tutorial which Ill post here.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. package andengine.test;
  3. import org.anddev.andengine.engine.Engine;
  4. import org.anddev.andengine.engine.camera.Camera;
  5. import org.anddev.andengine.engine.options.EngineOptions;
  6. import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
  7. import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
  8. import org.anddev.andengine.entity.scene.Scene;
  9. import org.anddev.andengine.entity.scene.background.ColorBackground;
  10. import org.anddev.andengine.entity.sprite.Sprite;
  11. import org.anddev.andengine.entity.util.FPSLogger;
  12. import org.anddev.andengine.opengl.texture.Texture;
  13. import org.anddev.andengine.opengl.texture.TextureOptions;
  14. import org.anddev.andengine.opengl.texture.region.TextureRegion;
  15. import org.anddev.andengine.opengl.texture.region.TextureRegionFactory;
  16. import org.anddev.andengine.ui.activity.BaseGameActivity;
  17.  
  18. /**
  19.  * @author Nicolas Gramlich
  20.  * @since 11:54:51 - 03.04.2010
  21.  */
  22. public class test extends BaseGameActivity {
  23.         // ===========================================================
  24.         // Constants
  25.         // ===========================================================
  26.  
  27.         private static final int CAMERA_WIDTH = 720;
  28.         private static final int CAMERA_HEIGHT = 480;
  29.  
  30.         // ===========================================================
  31.         // Fields
  32.         // ===========================================================
  33.  
  34.         private Camera mCamera;
  35.         private Texture mTexture;
  36.         private TextureRegion mFaceTextureRegion;
  37.  
  38.         // ===========================================================
  39.         // Constructors
  40.         // ===========================================================
  41.  
  42.         // ===========================================================
  43.         // Getter & Setter
  44.         // ===========================================================
  45.  
  46.         // ===========================================================
  47.         // Methods for/from SuperClass/Interfaces
  48.         // ===========================================================
  49.  
  50.         @Override
  51.         public Engine onLoadEngine() {
  52.                 this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
  53.                 return new Engine(new EngineOptions(true, ScreenOrientation.LANDSCAPE, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), this.mCamera));
  54.         }
  55.  
  56.         @Override
  57.         public void onLoadResources() {
  58.                 this.mTexture = new Texture(32, 32, TextureOptions.BILINEAR);
  59.                 this.mFaceTextureRegion = TextureRegionFactory.createFromAsset(this.mTexture, this, "gfx/face_box.png", 0, 0);
  60.  
  61.                 this.mEngine.getTextureManager().loadTexture(this.mTexture);
  62.         }
  63.  
  64.         @Override
  65.         public Scene onLoadScene() {
  66.                 this.mEngine.registerUpdateHandler(new FPSLogger());
  67.  
  68.                 final Scene scene = new Scene(1);
  69.                 scene.setBackground(new ColorBackground(0.09804f, 0.6274f, 0.8784f));
  70.  
  71.                 /* Calculate the coordinates for the face, so its centered on the camera. */
  72.                 final int centerX = (CAMERA_WIDTH - this.mFaceTextureRegion.getWidth()) / 2;
  73.                 final int centerY = (CAMERA_HEIGHT - this.mFaceTextureRegion.getHeight()) / 2;
  74.  
  75.                 /* Create the face and add it to the scene. */
  76.                 final Sprite face = new Sprite(centerX, centerY, this.mFaceTextureRegion);
  77.                 scene.getTopLayer().addEntity(face);
  78.  
  79.                 return scene;
  80.         }
  81.  
  82.         @Override
  83.         public void onLoadComplete() {
  84.  
  85.         }
  86.  
  87.         // ===========================================================
  88.         // Methods
  89.         // ===========================================================
  90.  
  91.         // ===========================================================
  92.         // Inner and Anonymous Classes
  93.         // ===========================================================
  94. }
  95.  
  96.  
  97. I just realized that I forgot to mention that I had to change the BaseExample to BaseGameActivity because eclipse couldnt find it and asked me to create it as a new class.  Now I realize thats something to do with it Im sure.  
  98.  
  99. Heres my manifest file
  100. [syntax="xml"]
  101.  
  102. <?xml version="1.0" encoding="utf-8"?>
  103. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  104.       package="andengine.test"
  105.       android:versionCode="1"
  106.       android:versionName="1.0">
  107.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  108.         <activity android:name="test"
  109.                   android:label="@string/app_name">
  110.             <intent-filter>
  111.                 <action android:name="android.intent.action.MAIN" />
  112.                 <category android:name="android.intent.category.LAUNCHER" />
  113.             </intent-filter>
  114.         </activity>
  115.  
  116.     </application>
  117.     <uses-sdk android:minSdkVersion="4" />
  118.     <uses-permission android:name="android.permission.WAKE_LOCK"/>
  119.  
  120. </manifest>
  121.  
  122. [/syntax]
  123.  
  124.  
  125.  
Parsed in 0.046 seconds, using GeSHi 1.0.8.4


So......do you think its something to do with my changing BaseExample to BaseGameActivity?
sambocrockett
 
Posts: 8
Joined: Thu Sep 23, 2010 9:08 am

Re: Getting started with AndEngine ...

Postby sambocrockett » Sat Oct 09, 2010 10:02 am

Oh and in the console there is nothing saying any errors just that the apk loaded to the device and it started. It installs it just doesnt want to open.....you can see it doing something and then it force closes and I get that message.
sambocrockett
 
Posts: 8
Joined: Thu Sep 23, 2010 9:08 am

Re: Getting started with AndEngine ...

Postby soshimo » Sun Oct 10, 2010 4:34 am

sambocrockett wrote:Oh and in the console there is nothing saying any errors just that the apk loaded to the device and it started. It installs it just doesnt want to open.....you can see it doing something and then it force closes and I get that message.


Try putting a breakpoint at the line that looks like this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. final int centerX = (CAMERA_WIDTH - this.mFaceTextureRegion.getWidth()) / 2;
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


See if it throws an exception. Alternatively you can set a breakpoint at this like:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  this.mFaceTextureRegion = TextureRegionFactory.createFromAsset(this.mTexture, this, "gfx/face_box.png", 0, 0);
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Step over that line and examine mFaceTextureRegion to make sure it's not null.
soshimo
 
Posts: 11
Joined: Thu Sep 09, 2010 6:50 am

Re: Getting started with AndEngine ...

Postby Lenti » Tue Oct 12, 2010 12:04 pm

Hello,
I am new here and have some (I guess beginner) probl ems getting started with the AndEngine. I alreadey have some expiriences with android, but not in the direction "engines"
However, the problem is the following: I followed the instructions in your video tutorial, but when I wanted to add the andengine jar to build path in eclipse, I realised I dont have this button. it simply doesn't exist.
Can you help me? thank you very much in advance!
Lenti
 
Posts: 3
Joined: Tue Oct 12, 2010 11:55 am

Re: Getting started with AndEngine ...

Postby brewhaha » Thu Oct 14, 2010 1:32 pm

Lenti wrote:Hello,
I am new here and have some (I guess beginner) probl ems getting started with the AndEngine. I alreadey have some expiriences with android, but not in the direction "engines"
However, the problem is the following: I followed the instructions in your video tutorial, but when I wanted to add the andengine jar to build path in eclipse, I realised I dont have this button. it simply doesn't exist.
Can you help me? thank you very much in advance!


as oldskool73 writes:
alternatively, you can do it manually by clicking the top level of your project and choosing properties -> java build path -> libraries -> add jars
brewhaha
 
Posts: 60
Joined: Mon Jul 12, 2010 1:06 pm

Re: Getting started with AndEngine ...

Postby brewhaha » Thu Oct 14, 2010 1:36 pm

sambocrockett wrote:Oh and in the console there is nothing saying any errors just that the apk loaded to the device and it started. It installs it just doesnt want to open.....you can see it doing something and then it force closes and I get that message.


Check this out:
http://developer.android.com/intl/fr/gu ... /ddms.html
brewhaha
 
Posts: 60
Joined: Mon Jul 12, 2010 1:06 pm

Re: Getting started with AndEngine ...

Postby Neverhood » Tue Oct 19, 2010 1:03 pm

Thank you very much for this nice tutorial! Made my first AndEngine project in a snap :)
Neverhood
 
Posts: 1
Joined: Tue Oct 19, 2010 1:02 pm

PreviousNext

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 26 guests