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 7063085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:40:18+00:00 2026-05-28T04:40:18+00:00

I am using this method in AndEngine to determine the scene being touched by

  • 0

I am using this method in AndEngine to determine the scene being touched by the user.

@Override
public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
     if(pSceneTouchEvent.isActionDown()) {
         Log.e("Arcade", "Scene Tapped");
                   //Simulate player jumping

     }
    return false;
}

What i want to do is when the scene is tapped, i want to allow the player to jump.

Now two things for this would it be better to use PathModifier, or MoveYModifier considering it is landscape mode?
If either please provide an example of such.
Thanks

EDIT:

ive managed to use Physics to simulate a jump using this..

@Override
public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
     if(pSceneTouchEvent.isActionDown()) {
         Log.e("Arcade", "Scene Tapped");

          final Vector2 velocity = Vector2Pool.obtain(mPhysicsWorld.getGravity().x * -0.5f,mPhysicsWorld.getGravity().y * -0.5f);
          body.setLinearVelocity(velocity);
          Vector2Pool.recycle(velocity);
         return true;
     }
    return false;
}

As you said in the answer by changing the gravity. The only issue is, when the user keeps touching the screen the sprites keep going up and up and up. How can i set it where the user can only click once and cant make him jump again until the sprite hits the ground, which is a rectangle?

  • 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-28T04:40:19+00:00Added an answer on May 28, 2026 at 4:40 am

    Use the MoveYModifier. remember, you can register as many modifiers as you want. So if, for example, the game a platform game and the character always moves on the X axis, and he can jumpt if he wants (Like Gravity Guy or Yoo Ninja, although these games change the gravity which is something else).

    You could do like:

    Entity playerEntity = ..//It doesn't matter if the player is a sprite, animated sprite, or anything else. So I'll just use Entity here, but you can declare your player as you wish.
    
    final float jumpDuration = 2;
    final float startX = playerEntity.getX();
    final float jumpHeight = 100;
    
    final MoveYModifier moveUpModifier = new MoveYModifier(jumpDuration / 2, startX, startX + jumpHeight);
    final MoveYModifier moveDownModifier = new MoveYModifier(jumpDuration / 2, startX + jumpHeight, startX);
    final SequenceEntityModifier modifier = new SequenceEntityModifier(moveUpModifier, moveDownModifier);
    
    playerEntity.registerEntityModifier(modifier);
    

    EDIT:

    For your second question:

    1. Create a variable boolean mIsJumping in your scene; When the jump starts – set it to true. If the user taps the screen and mIsJumping == true, don’t jump.
    2. Now, register a ContactListener to your PhysicsWorld. Whenever there is contact between the player and the ground, set mIsJumping to false.

    There are many samples of using ContactListeners in AndEngine forums, a quick search yields some. If you need an example, you can ask for one 🙂

    EDIT 2: ContactListener sample:

    1. Have 2 variables to hold IDs for the player and the ground: private static final String PLAYER_ID = "player", GROUND_ID = "ground";
    2. When you create the ground body and the player body, set their IDs as the user data: playerBody.setUserData(PLAYER_ID); and groundBody.setUserData(GROUND_ID);
    3. Create a ContactListener as a field in your scene:

      private ContactListener mContactListener = new ContactListener() { 
      /**
       * Called when two fixtures begin to touch.
       */
      public void beginContact (Contact contact) {
          final Body bodyA = contact.getFixtureA().getBody();
          final Body bodyB = contact.getFixtureB().getBody();
      
          if(bodyA.getUserData().equals(PLAYER_ID)) {
              if(bodyB.getUserData().equals(GROUND_ID))
                  mIsJumping = false;
          }
          else if(bodyA.getUserData().equals(GROUND_ID)) {
              if(bodyB.getUserData().equals(PLAYER_ID))
                  mIsJumping = false;
          }
      
      }
      
      /**
       * Called when two fixtures cease to touch.
       */
      public void endContact (Contact contact) { }
      
      /**
       * This is called after a contact is updated.
       */
      public void preSolve(Contact pContact) { }
      
      /**
       * This lets you inspect a contact after the solver is finished. 
       */
      public void postSolve(Contact pContact) { }
      };
      
    4. Lastly, register that contact listener: physicsWorld.setContactListener(mContactListener);

    EDIT 3:

    To move your sprite over the X axis, you can apply a force using Body.applyForce method, or apply an impulse using Body.applyLinearImpulse method. Play around with the arguments and find what works the next.

    The vector should consist a X part only; Try Vector2 force = Vector2Pool.obtain(50, 0);. Then apply the force this way: body.applyForce(force, body.getWorldCenter());.

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

Sidebar

Related Questions

when using this method public List<Field> getFieldWithoutId(List<Integer> idSections) throws Exception { try { Connection
I am using this method to move a sprite side to side in AndEngine.
I have this method in my RPC service: @Override public Entrata[] getEntrate(int from, int
I have a method in engine i'm using (andengine) : public final void setText(String
I am using this method in Andengine to scroll through a list of items,
Should I be using this method of throwing errors: if (isset($this->dbfields[$var])) { return $this->dbfields[$var];
I'm using this method to install an application, but it doesn't put the applications
I deployed an application using this method and it worked very good. However, there
I find myself using this method a ton to perform actions based on a
I'm currently using this method in calling batch files in vb.net: Private Sub Button3_Click(ByVal

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.