Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6998605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:25:57+00:00 2026-05-27T20:25:57+00:00

I have a question there. How i make character with gravity and available to

  • 0

I have a question there.
How i make character with gravity and available to walk properly i.e. what functions i need to use and how do i define fixtures? And do i need box2d physics world(i’m using tiled maps)?
So if you can, please tell me how to do 2d side scrolling platformer like mario with andengine.

My code what i’m trying to do :

    // Character:
    charactersprite = new Sprite(40, 0, this.character);
    charactersprite.setScaleX(0.65f);

    this.mScene.setOnSceneTouchListener( this);

    // PHYSICS
    final FixtureDef characterfictur = PhysicsFactory.createFixtureDef(0, 0f,0.5f);


    this.mScene.registerUpdateHandler(this.mPhysicsWorld);

    final Body body = PhysicsFactory.createBoxBody(this.mPhysicsWorld, charactersprite, BodyType.DynamicBody, characterfictur);

    this.mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(charactersprite, body, true, false));
    mScene.attachChild(charactersprite);

    createUnwalkableObjects(mTMXTiledMap);
    final PhysicsHandler physicsHandler = new PhysicsHandler(charactersprite);
    charactersprite.registerUpdateHandler(physicsHandler);


    // HUD
    HUD my = new HUD();
    Sprite forward = new Sprite( 50, CAMERA_HEIGHT - 170, forwardr){
        @Override
        public boolean onAreaTouched(TouchEvent pEvent, float pX, float pY){
            if(!pEvent.isActionUp()){
                charactersprite.getTextureRegion().setFlippedHorizontal(false);

            body.setLinearVelocity(new Vector2(CHAR_MOVING_SPEED,body.getLinearVelocity().y)); // Don't look at there
            //body.applyLinearImpulse(new Vector2(2,0), body.getPosition());

            }else{
                //body.applyLinearImpulse(new Vector2(0,0), body.getPosition());
                physicsHandler.setVelocity(0, 0);
                body.setLinearVelocity(new Vector2(0,body.getLinearVelocity().y)); // Don't look at there 
            }
            return false;

                       }
    };

And little forward :

private void createUnwalkableObjects(TMXTiledMap map){
    // Loop through the object groups

     for(final TMXObjectGroup group: map.getTMXObjectGroups()) {

             //if(group.getTMXObjectGroupProperties().containsTMXProperty("Zeme", "true")){
                     // This is our "wall" layer. Create the boxes from it

                     for(final TMXObject object : group.getTMXObjects()) {

                            final Rectangle rect = new Rectangle(object.getX(), object.getY(),object.getWidth(), object.getHeight());
                            final FixtureDef boxFixtureDef = PhysicsFactory.createFixtureDef(0, 0,1f);
                            PhysicsFactory.createBoxBody(this.mPhysicsWorld, rect, BodyType.StaticBody, boxFixtureDef);
                            rect.setVisible(false);
                            mScene.attachChild(rect);
                     }
             //}
     }

}

So it didn’t work properly. So what i’m doing wrong? Please help me.
Thank you very much!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:25:57+00:00Added an answer on May 27, 2026 at 8:25 pm

    Things you will need:

    • BoundCamera (to make bounds for your map)
    • chase entity (your player, so camera will follow your entity)
    • FixtureDef with little elasticity (to prevent player stopping suddenly on the ground)
    • create box bodies for your static objects (such as walls and so on)
    • things like jump – simply use setLinearVelocity

    Every ‘feature’ mentioned above, has its example – simply check and engine examples.

    In this thread, I provided some more tips about how to code such game: CLICK

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very theoretical question: Is there a way to ban the use
We have the question is there a performance difference between i++ and ++i in
I have seen this question: Are there any decent UI components for touch screen
Question Is there a way to have a method that will always run anytime
i have a question. There is application class in my program. It is inherited
I have a question about this question . I posted a reply there but
I have a question regarding using Semaphores HANDLE WINAPI CreateSemaphore(...); Is there anyway I
I have a simple question. Is there a way ( using reflections I suppose
There is a question I have been wondering about for ages and I was
I have a simple question about Java's XML API and I hope there's a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.