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

  • Home
  • SEARCH
  • 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 7073375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:55:19+00:00 2026-05-28T05:55:19+00:00

I am using andengine to implement a sprite being able to be dragged across

  • 0

I am using andengine to implement a sprite being able to be dragged across the screen using this.

So what i want to do is when the user taps any where on the screen make the sprite jump.

or move up and then move down.

What is the best way to go bout doing this with andengine?

  • 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-28T05:55:20+00:00Added an answer on May 28, 2026 at 5:55 am

    This should work:

    @Override
    public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
        if(pSceneTouchEvent.isActionDown()) { //Jump only if the user tapped, not moved his finger or something
            final Entity playerEntity = ...;//Get player entity here.
    
            final float jumpDuration = 2;
            final float startX = playerEntity.getX();
            final float jumpHeight = 100;
    
            final MoveYModifier moveUpModifier = new MoveYModifier(jumpDuration / 2, startX, startX - jumpHeight); // - since we want the sprite to go up.
            final MoveYModifier moveDownModifier = new MoveYModifier(jumpDuration / 2, startX + jumpHeight, startX);
            final SequenceEntityModifier modifier = new SequenceEntityModifier(moveUpModifier, moveDownModifier);
    
            playerEntity.registerEntityModifier(modifier);
            return true;
        }
        return false;
    }
    

    Keep in mind that, if you will use this, whenever there is an ACTION_DOWN event, you might miss some other event handlers for this (For example, if you have on-screen buttons, they will never handle the event).

    The way to handle it is to use add any other entities you want to receive touch events as touch areas for your scene, Scene.registerTouchArea(ITouchArea) does so. Sprites and AnimatedSprites implement ITouchArea, so you can use these.

    When a Scene receives a TouchEvent to handle, it will first let all the ITouchAreas you registered handle it, then if non of them consumed it, it will try the onSceneTouchEvenet method.

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

Sidebar

Related Questions

I am using AndEngine to add sprites to the screen and come across using
I am capturing the event of onSceneTouchEvent using AndEngine. What i want to do
Im developing a game for Android using AndEngine. As of now, I want to
i am making a game using andengine in android, in this game various sprites(eggs)
I am trying to implement Accelerometer in my game using Andengine and i also
I'm using AndEngine multi-touch functions to create multi-sprite for my game. But I've a
Hey everyone. I am using Appengine/Python and I haven't been able to fix a
I'm hoping someone's seen this. I've found no clues on Google. I'm using Google
I'm developing 2D Side scroll Android Game, using AndEngine and its BOX2D extension. I
Using AndEngine Physics Box2D i am trying to drag a body from side 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.