[TUTORIAL] How to use TexturedPolygon, ChainShape, DebugDraw

  ... tutorials on how to use AndEngine.

[TUTORIAL] How to use TexturedPolygon, ChainShape, DebugDraw

Postby RealMayo » Fri Mar 15, 2013 6:43 pm

THANKS

PREREQUISITES

OBJECTIVES
    This is a great way to create the ground in a 2D side scrolling game. This is how I made the ground in my game Traktor Digger.
    Create a concave polygon shape, fill it with a repeating graphic, surround it with chainshapes, add it to a physics world, activate the physics debug renderer to see the physical boundaries of the chainshapes. Touch the screen to add some physics bodies to bounce around and interact with your polygon shape in order to test it out.

PROCEDURE
    Simply create a new blank Android project in Eclipse.
    Link AndEngine and AndEnginePhysicsBox2DExtension and AndEngineDebugDrawExtension to the project as Library items.
    Copy and paste all of the code (below) and replace your main activity code with this code.
    Change the first line in the code to match the name of the package of your project.
    Create a folder in your project called "gfx". Add two graphics to this folder...
      Create one PNG graphic that is 128x128 pixels in size, and call it "dirt.png"
      Create one PNG graphic that is 32x32 pixels in size, and call it "grass.png"
    Also grab the following 4 graphics and add them to your gfx folder from here...
    https://github.com/nicolasgramlich/AndEngineExamples/tree/GLES2/assets/gfx
      face_box_tiled.png
      face_circle_tiled.png
      face_triangle_tiled.png
      face_hexagon_tiled.png
    Launch it to your phone and have fun!

CODE
    This is simply a modification of PhysicsExample.java
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.example.realmayo;
  2.  
  3. import static org.andengine.extension.physics.box2d.util.constants.PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT;
  4.  
  5. import org.andengine.engine.camera.Camera;
  6. import org.andengine.engine.options.EngineOptions;
  7. import org.andengine.engine.options.ScreenOrientation;
  8. import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
  9. import org.andengine.entity.primitive.Rectangle;
  10. import org.andengine.entity.primitive.TexturedPolygon;
  11. import org.andengine.entity.scene.IOnSceneTouchListener;
  12. import org.andengine.entity.scene.Scene;
  13. import org.andengine.entity.scene.background.Background;
  14. import org.andengine.entity.shape.IAreaShape;
  15. import org.andengine.entity.sprite.AnimatedSprite;
  16. import org.andengine.entity.util.FPSLogger;
  17. import org.andengine.extension.debugdraw.DebugRenderer;
  18. import org.andengine.extension.physics.box2d.PhysicsConnector;
  19. import org.andengine.extension.physics.box2d.PhysicsFactory;
  20. import org.andengine.extension.physics.box2d.PhysicsWorld;
  21. import org.andengine.extension.physics.box2d.util.Vector2Pool;
  22. import org.andengine.extension.physics.box2d.util.constants.PhysicsConstants;
  23. import org.andengine.input.sensor.acceleration.AccelerationData;
  24. import org.andengine.input.sensor.acceleration.IAccelerationListener;
  25. import org.andengine.input.touch.TouchEvent;
  26. import org.andengine.opengl.texture.TextureOptions;
  27. import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
  28. import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
  29. import org.andengine.opengl.texture.region.ITextureRegion;
  30. import org.andengine.opengl.texture.region.TiledTextureRegion;
  31. import org.andengine.opengl.vbo.VertexBufferObjectManager;
  32. import org.andengine.ui.activity.SimpleBaseGameActivity;
  33. import org.andengine.util.debug.Debug;
  34.  
  35. import android.hardware.SensorManager;
  36. import android.widget.Toast;
  37.  
  38. import com.badlogic.gdx.math.Vector2;
  39. import com.badlogic.gdx.physics.box2d.Body;
  40. import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
  41. import com.badlogic.gdx.physics.box2d.BodyDef;
  42. import com.badlogic.gdx.physics.box2d.ChainShape;
  43. import com.badlogic.gdx.physics.box2d.FixtureDef;
  44. import com.badlogic.gdx.physics.box2d.PolygonShape;
  45.  
  46. /**
  47.  * (c) 2010 Nicolas Gramlich
  48.  * (c) 2011 Zynga
  49.  *
  50.  * @author Nicolas Gramlich
  51.  * @since 18:47:08 - 19.03.2010
  52.  */
  53. public class MainActivity extends SimpleBaseGameActivity implements IAccelerationListener, IOnSceneTouchListener {
  54.         // ===========================================================
  55.         // Constants
  56.         // ===========================================================
  57.  
  58.         private static final int CAMERA_WIDTH = 720;
  59.         private static final int CAMERA_HEIGHT = 480;
  60.  
  61.         private static final FixtureDef FIXTURE_DEF = PhysicsFactory.createFixtureDef(1, 0.5f, 0.5f);
  62.  
  63.         // ===========================================================
  64.         // Fields
  65.         // ===========================================================
  66.  
  67.         private BitmapTextureAtlas mBitmapTextureAtlas;
  68.  
  69.         private TiledTextureRegion mBoxFaceTextureRegion;
  70.         private TiledTextureRegion mCircleFaceTextureRegion;
  71.         private TiledTextureRegion mTriangleFaceTextureRegion;
  72.         private TiledTextureRegion mHexagonFaceTextureRegion;
  73.  
  74. // REALMAYO - VARIABLES ***********************************************************************************************
  75.         public ITextureRegion mGrassTextureRegion;
  76.         public ITextureRegion mDirtTextureRegion;
  77. // ***********************************************************************************************
  78.  
  79.         private Scene mScene;
  80.  
  81.         private PhysicsWorld mPhysicsWorld;
  82.         private int mFaceCount = 0;
  83.  
  84.         // ===========================================================
  85.         // Constructors
  86.         // ===========================================================
  87.  
  88.         // ===========================================================
  89.         // Getter & Setter
  90.         // ===========================================================
  91.  
  92.         // ===========================================================
  93.         // Methods for/from SuperClass/Interfaces
  94.         // ===========================================================
  95.  
  96.         @Override
  97.         public EngineOptions onCreateEngineOptions() {
  98.                 Toast.makeText(this, "Touch the screen to add objects.", Toast.LENGTH_LONG).show();
  99.  
  100.                 final Camera camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
  101.  
  102.                 return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera);
  103.         }
  104.  
  105.         @Override
  106.         public void onCreateResources() {
  107.                 BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
  108.  
  109.                 this.mBitmapTextureAtlas = new BitmapTextureAtlas(this.getTextureManager(), 64, 128, TextureOptions.BILINEAR);
  110.                 this.mBoxFaceTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.mBitmapTextureAtlas, this, "face_box_tiled.png", 0, 0, 2, 1); // 64x32
  111.                 this.mCircleFaceTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.mBitmapTextureAtlas, this, "face_circle_tiled.png", 0, 32, 2, 1); // 64x32
  112.                 this.mTriangleFaceTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.mBitmapTextureAtlas, this, "face_triangle_tiled.png", 0, 64, 2, 1); // 64x32
  113.                 this.mHexagonFaceTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.mBitmapTextureAtlas, this, "face_hexagon_tiled.png", 0, 96, 2, 1); // 64x32
  114.                 this.mBitmapTextureAtlas.load();
  115.                  
  116. // REALMAYO - GRAPHICS ***********************************************************************************************
  117.                 BitmapTextureAtlas mDirtRepeatingAtlas1 = new BitmapTextureAtlas(this.getTextureManager(), 128, 128, TextureOptions.REPEATING_BILINEAR_PREMULTIPLYALPHA);
  118.                         mDirtTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(mDirtRepeatingAtlas1, this, "dirt.png", 0, 0);
  119.                         mDirtRepeatingAtlas1.load();
  120.                 BitmapTextureAtlas mGrassRepeatingAtlas1 = new BitmapTextureAtlas(this.getTextureManager(), 32, 32, TextureOptions.REPEATING_BILINEAR_PREMULTIPLYALPHA);
  121.                         mGrassTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(mGrassRepeatingAtlas1, this, "grass.png", 0, 0);
  122.                         mGrassRepeatingAtlas1.load();
  123. // ***********************************************************************************************
  124.                
  125.         }
  126.  
  127.         @Override
  128.         public Scene onCreateScene() {
  129.                 this.mEngine.registerUpdateHandler(new FPSLogger());
  130.  
  131.                 this.mScene = new Scene();
  132.                 this.mScene.setBackground(new Background(0, 0, 0));
  133.                 this.mScene.setOnSceneTouchListener(this);
  134.  
  135.                 this.mPhysicsWorld = new PhysicsWorld(new Vector2(0, SensorManager.GRAVITY_EARTH), false);
  136.  
  137.                 final VertexBufferObjectManager vertexBufferObjectManager = this.getVertexBufferObjectManager();
  138.                 final Rectangle ground = new Rectangle(0, CAMERA_HEIGHT - 2, CAMERA_WIDTH, 2, vertexBufferObjectManager);
  139.                 final Rectangle roof = new Rectangle(0, 0, CAMERA_WIDTH, 2, vertexBufferObjectManager);
  140.                 final Rectangle left = new Rectangle(0, 0, 2, CAMERA_HEIGHT, vertexBufferObjectManager);
  141.                 final Rectangle right = new Rectangle(CAMERA_WIDTH - 2, 0, 2, CAMERA_HEIGHT, vertexBufferObjectManager);
  142.  
  143.                 final FixtureDef wallFixtureDef = PhysicsFactory.createFixtureDef(0, 0.5f, 0.5f);
  144.                 PhysicsFactory.createBoxBody(this.mPhysicsWorld, ground, BodyType.StaticBody, wallFixtureDef);
  145.                 PhysicsFactory.createBoxBody(this.mPhysicsWorld, roof, BodyType.StaticBody, wallFixtureDef);
  146.                 PhysicsFactory.createBoxBody(this.mPhysicsWorld, left, BodyType.StaticBody, wallFixtureDef);
  147.                 PhysicsFactory.createBoxBody(this.mPhysicsWorld, right, BodyType.StaticBody, wallFixtureDef);
  148.  
  149.                 this.mScene.attachChild(ground);
  150.                 this.mScene.attachChild(roof);
  151.                 this.mScene.attachChild(left);
  152.                 this.mScene.attachChild(right);
  153.  
  154.                 this.mScene.registerUpdateHandler(this.mPhysicsWorld);
  155.  
  156. // REALMAYO - CHAINSHAPES AND POLYGON PRIMITIVE ***********************************************************************************************
  157.                 myGround();
  158. // ***********************************************************************************************
  159.                  
  160. // REALMAYO - DEBUGDRAW ***********************************************************************************************
  161.                 mScene.attachChild(new DebugRenderer(mPhysicsWorld, getVertexBufferObjectManager()));
  162. // ***********************************************************************************************
  163.  
  164.                 return this.mScene;
  165.         }
  166.  
  167.         @Override
  168.         public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pSceneTouchEvent) {
  169.                 if(this.mPhysicsWorld != null) {
  170.                         if(pSceneTouchEvent.isActionDown()) {
  171.                                 this.addFace(pSceneTouchEvent.getX(), pSceneTouchEvent.getY());
  172.                                 return true;
  173.                         }
  174.                 }
  175.                 return false;
  176.         }
  177.  
  178.         @Override
  179.         public void onAccelerationAccuracyChanged(final AccelerationData pAccelerationData) {
  180.  
  181.         }
  182.  
  183.         @Override
  184.         public void onAccelerationChanged(final AccelerationData pAccelerationData) {
  185.                 final Vector2 gravity = Vector2Pool.obtain(pAccelerationData.getX(), pAccelerationData.getY());
  186.                 this.mPhysicsWorld.setGravity(gravity);
  187.                 Vector2Pool.recycle(gravity);
  188.         }
  189.  
  190.         @Override
  191.         public void onResumeGame() {
  192.                 super.onResumeGame();
  193.  
  194.                 this.enableAccelerationSensor(this);
  195.         }
  196.  
  197.         @Override
  198.         public void onPauseGame() {
  199.                 super.onPauseGame();
  200.  
  201.                 this.disableAccelerationSensor();
  202.         }
  203.  
  204.         // ===========================================================
  205.         // Methods
  206.         // ===========================================================
  207.  
  208.         private void addFace(final float pX, final float pY) {
  209.                 this.mFaceCount++;
  210.                 Debug.d("Faces: " + this.mFaceCount);
  211.  
  212.                 final AnimatedSprite face;
  213.                 final Body body;
  214.  
  215.                 if(this.mFaceCount % 4 == 0) {
  216.                         face = new AnimatedSprite(pX, pY, this.mBoxFaceTextureRegion, this.getVertexBufferObjectManager());
  217.                         body = PhysicsFactory.createBoxBody(this.mPhysicsWorld, face, BodyType.DynamicBody, FIXTURE_DEF);
  218.                 } else if (this.mFaceCount % 4 == 1) {
  219.                         face = new AnimatedSprite(pX, pY, this.mCircleFaceTextureRegion, this.getVertexBufferObjectManager());
  220.                         body = PhysicsFactory.createCircleBody(this.mPhysicsWorld, face, BodyType.DynamicBody, FIXTURE_DEF);
  221.                 } else if (this.mFaceCount % 4 == 2) {
  222.                         face = new AnimatedSprite(pX, pY, this.mTriangleFaceTextureRegion, this.getVertexBufferObjectManager());
  223.                         body = MainActivity.createTriangleBody(this.mPhysicsWorld, face, BodyType.DynamicBody, FIXTURE_DEF);
  224.                 } else {
  225.                         face = new AnimatedSprite(pX, pY, this.mHexagonFaceTextureRegion, this.getVertexBufferObjectManager());
  226.                         body = MainActivity.createHexagonBody(this.mPhysicsWorld, face, BodyType.DynamicBody, FIXTURE_DEF);
  227.                 }
  228.  
  229.                 face.animate(200);
  230.  
  231.                 this.mScene.attachChild(face);
  232.                 this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(face, body, true, true));
  233.         }
  234.  
  235.         /**
  236.          * Creates a {@link Body} based on a {@link PolygonShape} in the form of a triangle:
  237.          * <pre>
  238.          *  /\
  239.          * /__\
  240.          * </pre>
  241.          */
  242.         private static Body createTriangleBody(final PhysicsWorld pPhysicsWorld, final IAreaShape pAreaShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
  243.                 /* Remember that the vertices are relative to the center-coordinates of the Shape. */
  244.                 final float halfWidth = pAreaShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
  245.                 final float halfHeight = pAreaShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
  246.  
  247.                 final float top = -halfHeight;
  248.                 final float bottom = halfHeight;
  249.                 final float left = -halfHeight;
  250.                 final float centerX = 0;
  251.                 final float right = halfWidth;
  252.  
  253.                 final Vector2[] vertices = {
  254.                                 new Vector2(centerX, top),
  255.                                 new Vector2(right, bottom),
  256.                                 new Vector2(left, bottom)
  257.                 };
  258.  
  259.                 return PhysicsFactory.createPolygonBody(pPhysicsWorld, pAreaShape, vertices, pBodyType, pFixtureDef);
  260.         }
  261.  
  262.         /**
  263.          * Creates a {@link Body} based on a {@link PolygonShape} in the form of a hexagon:
  264.          * <pre>
  265.          *  /\
  266.          * /  \
  267.          * |  |
  268.          * |  |
  269.          * \  /
  270.          *  \/
  271.          * </pre>
  272.          */
  273.         private static Body createHexagonBody(final PhysicsWorld pPhysicsWorld, final IAreaShape pAreaShape, final BodyType pBodyType, final FixtureDef pFixtureDef) {
  274.                 /* Remember that the vertices are relative to the center-coordinates of the Shape. */
  275.                 final float halfWidth = pAreaShape.getWidthScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
  276.                 final float halfHeight = pAreaShape.getHeightScaled() * 0.5f / PIXEL_TO_METER_RATIO_DEFAULT;
  277.  
  278.                 /* The top and bottom vertex of the hexagon are on the bottom and top of hexagon-sprite. */
  279.                 final float top = -halfHeight;
  280.                 final float bottom = halfHeight;
  281.  
  282.                 final float centerX = 0;
  283.  
  284.                 /* The left and right vertices of the heaxgon are not on the edge of the hexagon-sprite, so we need to inset them a little. */
  285.                 final float left = -halfWidth + 2.5f / PIXEL_TO_METER_RATIO_DEFAULT;
  286.                 final float right = halfWidth - 2.5f / PIXEL_TO_METER_RATIO_DEFAULT;
  287.                 final float higher = top + 8.25f / PIXEL_TO_METER_RATIO_DEFAULT;
  288.                 final float lower = bottom - 8.25f / PIXEL_TO_METER_RATIO_DEFAULT;
  289.  
  290.                 final Vector2[] vertices = {
  291.                                 new Vector2(centerX, top),
  292.                                 new Vector2(right, higher),
  293.                                 new Vector2(right, lower),
  294.                                 new Vector2(centerX, bottom),
  295.                                 new Vector2(left, lower),
  296.                                 new Vector2(left, higher)
  297.                 };
  298.  
  299.                 return PhysicsFactory.createPolygonBody(pPhysicsWorld, pAreaShape, vertices, pBodyType, pFixtureDef);
  300.         }
  301.        
  302.         private void myGround(){
  303. // REALMAYO - CUSTOM METHOD FOR BOTH CHAINSHAPES AND POLYGON PRIMITIVE ***********************************************************************************************
  304.                 final Vector2[] myCoordinates = {
  305.                                 new Vector2(100, 200),
  306.                                 new Vector2(400, 200),
  307.                                 new Vector2(250, 350),
  308.                                 new Vector2(225, 300),
  309.                                 new Vector2(100, 350)
  310.                 };
  311.                
  312.                 // CHAIN SHAPES - DRAW LINES BETWEEN ALL COORDINATES
  313.                 ChainShape myChain = new ChainShape();
  314.                 Vector2[] myV2 = new Vector2[myCoordinates.length];
  315.                 for(int i=0; i < myCoordinates.length; i++){   
  316.                         myV2[i] = new Vector2(myCoordinates[i].x/PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT, myCoordinates[i].y/PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT);
  317.                 }
  318.                 myChain.createChain(myV2);
  319.                 FixtureDef mFixtureDef = new FixtureDef();
  320.                 Body mChainBody;
  321.                 BodyDef mBodyDef = new BodyDef();
  322.                 mBodyDef.type = BodyType.KinematicBody;
  323.                 mChainBody = mPhysicsWorld.createBody(mBodyDef);
  324.                 mFixtureDef.shape = myChain;
  325.                 mChainBody.createFixture(mFixtureDef);
  326.                 myChain.dispose();
  327.                
  328.                 // TEXTURED POLYGON 1 - GRASS - TEXTURE REGION MUST BE FROM A REPEATING ATLAS
  329.                 float[] vertexX1 = new float[myV2.length];
  330.                 float[] vertexY1 = new float[myV2.length];
  331.                 for(int i=0; i < myV2.length; i++){    
  332.                         vertexX1[i]=myV2[i].x*PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT;
  333.                         vertexY1[i]=myV2[i].y*PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT;
  334.                 }
  335.                 final TexturedPolygon myGroundImage = new TexturedPolygon(0, 0, vertexX1, vertexY1, mGrassTextureRegion, getVertexBufferObjectManager());
  336.                 mScene.attachChild(myGroundImage);
  337.                
  338.                 // TEXTURED POLYGON 2 - DIRT - TEXTURE REGION MUST BE FROM A REPEATING ATLAS
  339.                 final float mGrassHeight = mGrassTextureRegion.getHeight();
  340.                 float[] vertexX2 = new float[myV2.length];
  341.                 float[] vertexY2 = new float[myV2.length];
  342.                
  343.                 for(int i=0; i < myV2.length; i++){    
  344.                                 vertexX2[i]=myV2[i].x*PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT;
  345.                                 vertexY2[i]=myV2[i].y*PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT+(mGrassHeight);
  346.                 }
  347.                 final TexturedPolygon myGroundImage3 = new TexturedPolygon(0, 0, vertexX2, vertexY2, mDirtTextureRegion, getVertexBufferObjectManager());
  348.                 mScene.attachChild(myGroundImage3);    
  349.                
  350.         }
  351.  
  352. }
  353.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
User avatar
RealMayo
 
Posts: 1694
Joined: Sat Sep 03, 2011 9:25 pm
Location: Chicago, IL

Re: [TUTORIAL] How to use TexturedPolygon, ChainShape, Debug

Postby Destiny » Fri Mar 15, 2013 8:07 pm

This is a brilliant and an exceptional tutorial to all those trying to figure out the usage of TexturedPolygon, ChainShape, DebugDraw.....

Thank U very much RealMayo for shelling out ur valuable time to create this turorial.....

Regards
Destiny
Destiny
 
Posts: 53
Joined: Thu Jul 26, 2012 2:49 pm

Re: [TUTORIAL] How to use TexturedPolygon, ChainShape, Debug

Postby falsedmitri » Fri Jun 14, 2013 5:45 pm

Below is a screenshot of the display. Is this correct?

chainshape.png
chainshape.png (53.49 KiB) Viewed 6637 times
-----------------------------------------
Some LiveWallpapers:
https://play.google.com/store/search?q=qhosinyawi&c=apps
User avatar
falsedmitri
 
Posts: 170
Joined: Tue Mar 19, 2013 10:20 pm

Re: [TUTORIAL] How to use TexturedPolygon, ChainShape, Debug

Postby RealMayo » Fri Jun 14, 2013 6:54 pm

Yes that is correct.
The white line represents the ChainShapes and is displayed via DebugDraw. This example shows you that it is possible to have some of the TexturedPolygon exist outside of the chainshape area. This is to emphasize the fact that physics bodies will only interact with the ChainShapes, not with the TexturedPolygon. Furthermore, this example demonstrates that you can make both concave and convex polygons using TexturedPolygons and ChainShapes. Essentially what we have done in this example is create a grass/green TexturedPolygon. Then overlayed on top of that (and offset a little bit below it) another TexturedPolygon which is the dirt/brown. Then overlayed specifically on the grass TexturedPolygon is a perimeter of ChainShapes.
User avatar
RealMayo
 
Posts: 1694
Joined: Sat Sep 03, 2011 9:25 pm
Location: Chicago, IL

Re: [TUTORIAL] How to use TexturedPolygon, ChainShape, Debug

Postby shani74 » Wed Jun 26, 2013 8:45 am

hi RealMayo, i used this code but i got following output. Where i am getting wrong.
Attachments
output.png
output.png (34.73 KiB) Viewed 6534 times
shani74
 
Posts: 116
Joined: Thu Feb 23, 2012 5:34 am

Re: [TUTORIAL] How to use TexturedPolygon, ChainShape, Debug

Postby shihab_returns » Mon Jul 15, 2013 11:09 am

thanks for the tuts @RealMayo.

I managed to draw terrain like this.
Image

Now I want to make it a sinusoidal wave view. Like @Matthias did. Any idea?

Image

Waiting for your super knock. ;)
shihab_returns
 
Posts: 105
Joined: Tue Oct 16, 2012 8:48 am
Location: Dhaka

Re: [TUTORIAL] How to use TexturedPolygon, ChainShape, Debug

Postby RealMayo » Mon Jul 15, 2013 4:37 pm

Hi shihab
You can try using Matthias level editor which produces such terrain...
http://www.andengine.org/forums/tools/android-xml-level-editor-t10188.html
User avatar
RealMayo
 
Posts: 1694
Joined: Sat Sep 03, 2011 9:25 pm
Location: Chicago, IL

Re: [TUTORIAL] How to use TexturedPolygon, ChainShape, Debug

Postby shihab_returns » Tue Jul 16, 2013 7:25 am

thanks a lot.
After I installing the LevelEditor.apk , I found a blank screen.

edited: Solved the issue.
shihab_returns
 
Posts: 105
Joined: Tue Oct 16, 2012 8:48 am
Location: Dhaka

Re: [TUTORIAL] How to use TexturedPolygon, ChainShape, Debug

Postby raphael » Sat Aug 24, 2013 3:12 pm

shihab_returns wrote:thanks a lot.
After I installing the LevelEditor.apk , I found a blank screen.

edited: Solved the issue.

for the next, I had to copy Mylevels and NextLevel_Preferences.xml in / mnt / sdcard and then walk it.
raphael
 
Posts: 14
Joined: Wed Feb 20, 2013 6:08 pm

Re: [TUTORIAL] How to use TexturedPolygon, ChainShape, Debug

Postby RealMayo » Wed Nov 13, 2013 6:43 pm

If you are using AndEngine Anchor Center, then none of this will work. Instead you should use the Mesh Animation feature created by forum member IFL...
http://www.andengine.org/forums/features/new-features-t10876.html
User avatar
RealMayo
 
Posts: 1694
Joined: Sat Sep 03, 2011 9:25 pm
Location: Chicago, IL

Next

Return to Tutorials

Who is online

Users browsing this forum: Google Adsense [Bot] and 25 guests