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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:55:52+00:00 2026-05-25T14:55:52+00:00

I am working on a game in AndEngine . In that I am able

  • 0

I am working on a game in AndEngine. In that I am able to move an Object in Right to Left, Top to Bottom and vice-versa. But, my issue is that how can I move the Sprite object in the Direction of Fling? It means if users Fling’s in any direction the Sprite Object should move on the co-ordinates of the fling and should move on.

If anyone can suggest about, how to get the exact X and Y co-ordinates would also do, I can manage to move the Sprite Object myself on the co-ordinates.

You can also see the VIDEO – Pirates Subs

In the video the Launcher coming on the FLING is what I am looking for, from any direction.

Thanks in Advance.
Suri Sahani.

  • 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-25T14:55:52+00:00Added an answer on May 25, 2026 at 2:55 pm

    Well, you can try this code…..

    float slope = (y2 - y1) / (x2 - x1);
    float angle = (float) Math.atan(slope);
    float angleInDegree = (float) Math.toDegrees(angle);
    
    c = y1 - (slope * x1);
    

    onFling() method look’s like this, for all direction.

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,float velocityY) {
    
    float c;
    // Checks if LifeLine is there or not and enable or disable Fling
    // Operation.
    float sx = 0, sy = 0;
    float x1 = e1.getX();
    float y1 = e1.getY();
    
    float x2 = e2.getX();
    float y2 = e2.getY();
    
    float slope = (y2 - y1) / (x2 - x1);
    float angle = (float) Math.atan(slope);
    float angleInDegree = (float) Math.toDegrees(angle);
    
    c = y1 - (slope * x1);
    
    /**
    * bottom right to left top
    */
    if (x1 > x2 && y1 > y2) {
    sx = CAMERA_WIDTH;
    sy = (slope * sx) + c;
    
    missile = new Missile(sx, sy,
    this.mFaceTextureRegionMissileLeftToRight);
    missile.setVelocity(-(float) (600 * (Math.cos(angle))),
    -(float) (600 * (Math.sin(angle))));
    
    scene.getTopLayer().addEntity(missile);
    
    missile.setRotation(angleInDegree + 180);
    
    }
    /**
    * left top corner to right
    */
    else if (x2 > x1 && y2 > y1) {
    sx = -100;
    sy = (slope * sx) + c;
    missile = new Missile(sx, sy,
    this.mFaceTextureRegionMissileLeftToRight);
    missile.setVelocity((float) (300 * (Math.cos(angle))),
    (float) (300 * (Math.sin(angle))));
    scene.getTopLayer().addEntity(missile);
    missile.setRotation(angleInDegree);
    }
    /**
    * left bottom corner to right up
    */
    else if (x2 > x1 && y1 > y2) {
    sx = -100;
    sy = (slope * sx) + c;
    missile = new Missile(sx, sy,
    this.mFaceTextureRegionMissileLeftToRight);
    missile.setVelocity((float) (300 * (Math.cos(angle))),
    (float) (300 * (Math.sin(angle))));
    scene.getTopLayer().addEntity(missile);
    missile.setRotation(angleInDegree);
    }
    
    /**
    * Right corner to left bottom down
    */
    else if (x1 > x2 && y2 > y1) {
    sx = CAMERA_WIDTH;
    sy = (slope * sx) + c;
    missile = new Missile(sx, sy,
    this.mFaceTextureRegionMissileLeftToRight);
    missile.setVelocity((float) (-600 * (Math.cos(angle))),
    -(float) (600 * (Math.sin(angle))));
    scene.getTopLayer().addEntity(missile);
    missile.setRotation(angleInDegree + 180);
    }
    return false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright so here is my issue. I'm working a game engine that will eventually
I'm working With Game Center right now and I have a issue with GC.
I'm working on a game (C#) that uses a Robocode-like programming model: participants inherit
I am working on game engine prototype and have the following question: Right now
I working on a game but I have a problem with the initialization of
Im working on a game in Java and having an issue (i believe its
Working on a game project that involves a scripting language that I want to
I'm working on a game which has different modules that I am developping on
I'm working on a game right now where I'm going to have paths dynamically
I'm working on a little game/project and I decide to use AndEngine for it

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.