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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:18:01+00:00 2026-05-23T02:18:01+00:00

I want to know how is it possible,I could have an Object drawn at

  • 0

I want to know how is it possible,I could have an Object drawn at a certain point and move to the point that is touched on the screen. I am trying to use it for my game where when the user touches on the screen, the gun fires from the position of the player, but the player is stationary.

Thanks in advance.

P.S.

Is there a visual graphic of some sort that shows where every plot is on android.

  • 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-23T02:18:02+00:00Added an answer on May 23, 2026 at 2:18 am

    I don’t know what kind of library you’re using to draw all of your things, but that basically doesn’t matter since you only need to know two things in order to do this:

    Without going into specifics on vector geometry:

    1. You need to calculate the direction (x and y component) that the projectile moves in depending on your mouses position. You get this direction by simply subtracting the position of the mouse from the position of the player:

    //x component of direction
    float direction_x = mousePosition.x - playerPosition.x;
    //y component of direction
    float direction_y = mousePosition.y - playerPosition.y;
    

    In order to just get a direction instead of adding a velocity component to this vector, you need to normalize it (so it has a length of 1):

    float length =(float) Math.sqrt(direction_x*direction_x + direction_y*direction_y);
    direction_x /= length;
    direction_y /= length;
    

    You then need to update the projectiles position by adding the direction_x and direction_y components to it, multiplied by the speed that you want the projectile to have (This process is called linear interpolation, by the way):

    projectile_x += direction_x*speed;
    projectile_y += direction_y*speed;
    

    If you have some way of measuring the time between two frames, the speed variable should depend on the elapsed time between those frames, in order to create smooth movements on different platforms.

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

Sidebar

Related Questions

Basically, I just want to know if its possible to use Nhibernate to migrate
So what I want to know is whether the following is possible. I have
I have some data inside this variable and I want to know how could
tl;dr-edition: I have a compilation I know that will fail, but want the subset
i want know if is possible, to get a specific element value of a
i want to know if it possible to access the browser bookmarks via Flash.
I am creating a CMS and want to know if its possible to download
I want to know whether it is possible to commit to a previous version.
I want to know if it's possible to register a type library without using
I want to know if it is possible to stream data from the server

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.