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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:01:03+00:00 2026-06-13T20:01:03+00:00

Hello everyone I’m trying to develop a game like Jetpack so i want to

  • 0

Hello everyone I’m trying to develop a game like Jetpack so i want to set a gravity that normally push down and when the user tap the screen the gravity change it push up. I searched for a week a tutorial that explain how to do that but I didn’t find what I search. Someone can explain me how to do that or post a link to a tutorial ?

Thank you !!

    main = new Sprite(sX, sY, mainTextureRegion);
    main.setScale(1);
    main.setFlippedHorizontal(true);
    scene.attachChild(main);
    mPhysicsWorld = new PhysicsWorld(new Vector2(0, SensorManager.GRAVITY_EARTH), false);
    final FixtureDef objectFixtureDef = PhysicsFactory.createFixtureDef(1, 0.5f, 0.5f);
    final Body body = PhysicsFactory.createBoxBody(mPhysicsWorld, main, BodyType.DynamicBody, objectFixtureDef);
    mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(main, body, true, true));
    final Vector2 gravity = new Vector2(0, 5f);
    mPhysicsWorld.setGravity(gravity);

    scene.registerUpdateHandler(new IUpdateHandler() {
        @Override
        public void onUpdate(float pSecondsElapsed) {

      }

        @Override
        public void reset() {
            // TODO Auto-generated method stub

        }});
  • 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-06-13T20:01:04+00:00Added an answer on June 13, 2026 at 8:01 pm

    When the user touches the screen, you shouldn’t change the gravity because it is not suppose to be done like that.
    When he touches the screen, just apply a LinearImpulse (check if it not already at maximum speed) or something like that to make it go upper. The gravity shouldn’t change as it should always attract all of your physics objects down. If your change the gravity you change the behavior of all your objects, not only the player one.

    EDIT

    To have the physics engine to work you have to call the step() method of the PhysicsWorld class at each render. The problem with Andengine is that you don’t directly access the render() method as Andengine handle it at all.
    So what you have to do is to register a IUpdateHandler on the Engine object that you return in your onLoadEngine() method.
    This way the onUpdate() method of the interface will be called at each render and here you can call the step() method to get the physics part to work. The float value tells you about how many seconds elapsed since last render but you don’t have to take care of that. The method is called multiple times per second.

    Hope it helps.

    EDIT 2

    I think this should work :

    //on the Scene object or on the Engine one
    scene.registerUpdateHandler(new IUpdateHandler() {
        @Override
        public void onUpdate(float pSecondsElapsed) {
            mPhysicsWorld.onUpdate(pSecondsElapsed);
        }
    
        @Override
        public void reset() {}
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello everyone I am trying to make a script that steps through a list
hello everyone im trying to create this tweak that copies a file from one
Hello everyone I'm trying to convert a PKCS#8 private key that I generate in
Hello everyone I'm trying to use sharp property like photoshop in Css but how
Hello everyone I have a problem. I want to do a GridView with a
Hello everyone I am trying to resize an image of 700kb with imagecreatefromjpeg. This
Hello everyone. I'm using Silverlight webbrowser control, and I'm having some problems with that.
hello everyone i want validate the type of file being uploaded on sever to
Hello everyone i need some help. I'm trying to make an application for mac
hello everyone i am new bie in iphone development i want to connect to

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.