[TUTORIAL] Getting Started with AndEngine

  ... tutorials on how to use AndEngine.

Re: [TUTORIAL] UPDATED - Getting Started with AndEngine

Postby RealMayo » Sun Jan 08, 2012 5:33 am

ikoymaster wrote:none of the "text" examples and the other examples making use of AndEngine's "text" are not working... I need help!!!

I'm using huawei IDEOS...

Hmm, they all work for me!
What might help is if you update all of the extensions AND the examples by right-clicking on them, then choose Team, then choose Pull.
User avatar
RealMayo
 
Posts: 1681
Joined: Sat Sep 03, 2011 9:25 pm
Location: Chicago, IL

Re: [TUTORIAL] UPDATED - Getting Started with AndEngine

Postby FribourG » Wed Jan 11, 2012 8:09 am

Thanks for the tutorial, it works great.

Inside my AndEngine projects, I have .git folders. In AndEngineExamples, that folder is about 82MB. Is it normal ?
FribourG
 
Posts: 1
Joined: Wed Jan 11, 2012 8:00 am

Re: [TUTORIAL] UPDATED - Getting Started with AndEngine

Postby bos » Fri Jan 13, 2012 4:51 am

ikoymaster wrote:none of the "text" examples and the other examples making use of AndEngine's "text" are not working... I need help!!!

I'm using huawei IDEOS...


Same here, kills Eclipse big time:

01-13 03:12:44.612: E/AndroidRuntime(446): java.lang.StackOverflowError
01-13 03:12:44.612: E/AndroidRuntime(446): at org.anddev.andengine.ui.activity.BaseGameActivity.getFontManager(BaseGameActivity.java:137)
[50+ copies of the last line]
bos
 
Posts: 44
Joined: Fri Jan 13, 2012 4:15 am

Re: [TUTORIAL] UPDATED - Getting Started with AndEngine

Postby FX2011 » Fri Jan 13, 2012 5:16 pm

In your second video near marker 3:48, one right clicks the examples then Build Path followed by Link Source. My Eclipse doesn't show this option. It only has one choice, Configure Build Path.

My Eclipse is Eclipse IDE for Java Developers

Version: Indigo Service Release 1
Build id: 20110916-0149
Eclipse IDE for Java Developers 1.4.1.20110909-1818

O/S - Vista Ultimate 64

Am I missing something? I was fine up to this point , using the following tutorial video...
http://www.youtube.com/watch?v=oykGQvHw ... plpp_video
FX2011
 
Posts: 2
Joined: Fri Jan 13, 2012 5:09 pm

Re: [TUTORIAL] UPDATED - Getting Started with AndEngine

Postby RealMayo » Sat Jan 14, 2012 12:24 am

FX2011 wrote:In your second video near marker 3:48, one right clicks the examples then Build Path followed by Link Source. My Eclipse doesn't show this option. It only has one choice, Configure Build Path.

I believe you can link source if you right click on your project and choose properties. I think one of the tabs in the properties lets you do it.
Nevertheless if you want to try AndEngine GLES2 then you do not need to link source, because it uses library projects instead. You can see my other tutorial for GLES2.
Actually, I think you might be able to use GLES1 as library projects as well. You can try to do that and see what happens.
User avatar
RealMayo
 
Posts: 1681
Joined: Sat Sep 03, 2011 9:25 pm
Location: Chicago, IL

Re: [TUTORIAL] UPDATED - Getting Started with AndEngine

Postby spiral » Mon Feb 13, 2012 9:51 pm

Thanks RealMayo. Total champion.

After watching your first video for GLES2, I found i had to do one extra step:
Im running ubuntu 11.10 with the software-center version of eclipse. (indigo) fresh install.
Some others might have this issue, so im posting it here.

I was getting this:
one of these for each extension (not includeing andengine itself):
The container 'Library Projects' references non existing library '/home/me/workspace/AndEngine/bin/andengine.jar' AndEngineMODPlayerExtension Build path Build Path Problem

And i this for everything (includeing andengine)
The project cannot be built until build path errors are resolved AndEngine Unknown Java Problem

I found that eclipse would not build the andengine library so i had to do it myself with an export like this.
1. right click on andengine project.
2. click export.
3. java -> jar file
4. select just the src folder
5. make the export destination in the bin directory.

Then i could successfully run all examples as built from source. (including text, physics, svg, etc, i diddnt try them all)
spiral
 
Posts: 15
Joined: Tue May 31, 2011 12:08 am

Re: [TUTORIAL] UPDATED - Getting Started with AndEngine

Postby cleisonmp » Thu Feb 16, 2012 1:10 am

hi, maybe it's a stupid question and the wrong place but, can someone point me the direction to make physics collisions acording to the sprite, not just as objects like circle boxes, hexagons?
cleisonmp
 
Posts: 9
Joined: Thu Feb 09, 2012 7:46 pm

Re: [TUTORIAL] UPDATED - Getting Started with AndEngine

Postby RealMayo » Thu Feb 16, 2012 1:38 am

cleisonmp wrote:hi, maybe it's a stupid question and the wrong place but, can someone point me the direction to make physics collisions acording to the sprite, not just as objects like circle boxes, hexagons?

If you want to detect collision, you need:
1) Box2D Extension connected to your project
2) At least 2 separate bodies that would collide with eachother

A body can be any shape you want. If you already have a sprite that you want to use, then you will need to construct your body so that it has a similar shape as you sprite. Then you attach your sprite to the body. To give your body a shape, you need to add 1 or more fixtures to the body.

Think of a BODY as just a shapless blob. The body automatically conforms to exactly fit the FIXTURES that you attach to it.

See here for more information about fixtures...
http://www.andengine.org/forums/gles1/complex-collision-surface-t5593.html#p24822

See here for more information about detecting collision...
http://www.andengine.org/forums/physics-box2d-extension/how-do-you-setuserdata-with-contactlistener-t6803-10.html#p29934
User avatar
RealMayo
 
Posts: 1681
Joined: Sat Sep 03, 2011 9:25 pm
Location: Chicago, IL

Re: [TUTORIAL] UPDATED - Getting Started with AndEngine

Postby cleisonmp » Thu Feb 16, 2012 2:23 am

RealMayo wrote:
cleisonmp wrote:hi, maybe it's a stupid question and the wrong place but, can someone point me the direction to make physics collisions acording to the sprite, not just as objects like circle boxes, hexagons?

If you want to detect collision, you need:
1) Box2D Extension connected to your project
2) At least 2 separate bodies that would collide with eachother

A body can be any shape y...........]


UPDATED

thx for tour answer, I'm quite there I think, but all of then start on the same position X=1,Y=1, not random like before, and if I change "mBodyDef.position.x = 1;" for other value != 1, it doesn't appear on screen.

Here is the code, I've used avhelper to get the vertex cordinates.
Image

ADD FRUIT
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private void addFruit() {              
  2.         final MySprite fruit;
  3.         final Body body;
  4.        
  5.         this.fruitCount++;     
  6.        
  7.         fruit = new MySprite(0, 0, Game.this.mFruitTextureRegion,Game.this.getVertexBufferObjectManager());
  8.        
  9.         float newFruitX = Game.this.mRandom.nextInt(CAMERA_WIDTH - 5);
  10.        
  11.         float lL = (float) fruit.getWidth();; // Left Limit
  12.         float rL = CAMERA_WIDTH - (float) fruit.getWidth(); // Right Limit
  13.  
  14.         // Double Check That New X Coordinates are within Limits
  15.         if (newFruitX < lL)
  16.                 newFruitX = lL;
  17.         else if (newFruitX > rL)
  18.                 newFruitX = rL;
  19.         fruit.setPosition(newFruitX, 0);               
  20.  
  21.         //physics stuff
  22.         body = createAppleBody(Game.this.mPhysicsWorld,fruit,BodyType.DynamicBody,FIXTURE_DEF,newFruitX);
  23.         body.resetMassData();  
  24.                        
  25.         final PhysicsConnector fruitPhysicsConnector = new PhysicsConnector(fruit, body, true, true);
  26.         Game.this.mPhysicsWorld.registerPhysicsConnector(fruitPhysicsConnector);
  27.        
  28.         //fruit.animate();
  29.         fruit.setUserData(false);
  30.         fruit.setToDelete(false);
  31.         fruit.setLost(false);
  32.         Game.this.mScene.registerTouchArea(fruit);
  33.         Game.this.mScene.attachChild(fruit);           
  34.        
  35.         final PhysicsHandler physicsHandler = new PhysicsHandler(fruit);               
  36.         fruit.registerUpdateHandler(physicsHandler);           
  37.        
  38.         body.setLinearVelocity(Game.this.fruitXSpeedForLevel, Game.this.fruitYSpeedForLevel);
  39.        
  40.         Game.this.fruits.add(fruit); //insert into fruit array
  41. }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


POLYGON STUFF
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private static Body createAppleBody(final PhysicsWorld pPhysicsWorld,final IAreaShape mSprite,final BodyType pBodyType,final FixtureDef pFixtureDef, final float pFruitX){
  2.        
  3.         final BodyDef mBodyDef = new BodyDef();
  4.         mBodyDef.type = pBodyType;
  5.         mBodyDef.position.x = 1;
  6.         mBodyDef.position.y = 1;
  7.         final Body mBody = pPhysicsWorld.createBody(mBodyDef);
  8.         final float width = mSprite.getWidthScaled() / PIXEL_TO_METER_RATIO_DEFAULT;
  9.         final float height = mSprite.getHeightScaled() / PIXEL_TO_METER_RATIO_DEFAULT;
  10.          
  11.          
  12.         // =============================================
  13.         // poly 1
  14.         final PolygonShape mPoly = new PolygonShape();                         
  15.         final Vector2[] pVertices = {                                      
  16.         //autogenerated code
  17.         new Vector2(-0.10146f*width, +0.13910f*height),
  18.         new Vector2(+0.05500f*width, +0.37631f*height),
  19.         new Vector2(-0.06108f*width, +0.42173f*height),
  20.         new Vector2(-0.17717f*width, +0.38135f*height)                 
  21.         };
  22.         mPoly.set(pVertices);
  23.         pFixtureDef.shape = mPoly;
  24.         mBody.createFixture(pFixtureDef);
  25.         mPoly.dispose();
  26.         // =============================================               
  27.    
  28.    // =============================================
  29.         // poly 2
  30.         final PolygonShape mPoly2 = new PolygonShape();
  31.         final Vector2[] pVertices2 = {                                     
  32.         //autogenerated code
  33.         new Vector2(-0.33867f*width, -0.31514f*height),
  34.         new Vector2(-0.08632f*width, -0.40094f*height),
  35.         new Vector2(+0.28211f*width, +0.17443f*height),
  36.         new Vector2(-0.12165f*width, +0.15928f*height),
  37.         new Vector2(-0.34877f*width, +0.13910f*height),
  38.         new Vector2(-0.46485f*width, -0.05774f*height)                 
  39.         };
  40.         mPoly2.set(pVertices2);
  41.         pFixtureDef.shape = mPoly2;
  42.         mBody.createFixture(pFixtureDef);
  43.         mPoly2.dispose();
  44.         // =============================================                               
  45.        
  46.         // =============================================
  47.         // poly 2
  48.         final PolygonShape mPoly3 = new PolygonShape();
  49.         final Vector2[] pVertices3 = {                                     
  50.         //autogenerated code
  51.         new Vector2(-0.09137f*width, -0.41103f*height),
  52.         new Vector2(+0.21146f*width, -0.40094f*height),
  53.         new Vector2(+0.43353f*width, -0.13849f*height),
  54.         new Vector2(+0.42848f*width, +0.07348f*height),
  55.         new Vector2(+0.25688f*width, +0.17443f*height)                 
  56.         };
  57.         mPoly3.set(pVertices3);
  58.         pFixtureDef.shape = mPoly3;
  59.         mBody.createFixture(pFixtureDef);
  60.         mPoly3.dispose();
  61.         // =============================================
  62.        
  63.         return mBody;
  64.  
  65. }
Parsed in 0.039 seconds, using GeSHi 1.0.8.4
cleisonmp
 
Posts: 9
Joined: Thu Feb 09, 2012 7:46 pm

Re: [TUTORIAL] UPDATED - Getting Started with AndEngine

Postby offtravel » Fri Feb 17, 2012 6:05 pm

I have a problem in porting the project in the new andengine, someone can help me?
post30395.html#p30395
offtravel
 
Posts: 6
Joined: Tue Oct 11, 2011 8:36 pm

PreviousNext

Return to Tutorials

Who is online

Users browsing this forum: Alexa [Bot], dichhv, Google Feedfetcher and 15 guests