title: LibGdx - Move Sprite in the direction of another
body: <p>I'm kind new to LibGdx and I'm still learning. I'm working on a small game project to learn this nice framework. However, I'm having some issues with my game. My game is a top down shooter. There is a human character(space marine) that has to shoot an alien, which will be always moving in his direction until it  dies. My code doesn't have any bullets yet.I was able to make the shooter rotate in the direction of the cursor, as well, the alien rotate in the direction of the shooter, but I can't make the alien move in his direction. I'm pretty sure that my method that does that is completely wrong. I've tried a lot to fix it , but I can't get it fixed ! I appreciate your attention guys !
  You can find the full code of the main class here:
   <a href="https://github.com/Igor-Lopes/LibGdx/blob/master/Splash.java#L125" rel="nofollow">https://github.com/Igor-Lopes/LibGdx/blob/master/Splash.java#L125</a> </p>
  
  <pre><code>public void moveAlien() {
      float mX = 0;
      float mY = 0;
      int velocity = 50;
      vAlien = new Vector2(-1 * (float) Math.sin(Alienbody.getAngle()) * velocity,
              (float) Math.cos(Alienbody.getAngle() * velocity));
  
      mX = (float) Math.cos(Math.toRadians(spacemarine.getRotation()));
      mY = (float) Math.sin(Math.toRadians(spacemarine.getRotation()));
  
      vAlien.x = mX;
      vAlien.y = mY;
      if (vAlien.len() &gt; 0) {
          vAlien = vAlien.nor();
      }
      vAlien.x = vAlien.x * velocity;
      vAlien.y = vAlien.y * velocity;
      vAlien.x += vAlien.x * Gdx.graphics.getDeltaTime();
      vAlien.y += vAlien.x * Gdx.graphics.getDeltaTime();
  }
  
  public float rotateMarine() {
      float angle = 0;
      float mouseX = 0;
      float mouseY = 0;
      mouseX = Gdx.input.getX();
      mouseY = 677 - Gdx.input.getY();
      angle = (float) Math.toDegrees(Math.atan2(mouseX - spacemarine.getX(),
              mouseY - spacemarine.getY()));
      if (angle &lt; 0)
          angle += 360;
      spacemarine.setRotation(angle * -1);
      return angle;
  }
  
  public float rotateAlien(Sprite s, float posX, float posY) {
      float angle = 0;
      float mouseX = 0;
      float mouseY = 0;
      mouseX = posX;
      mouseY = posY;
      angle = (float) Math.toDegrees(Math.atan2(mouseX - s.getX(), mouseY - s.getY()));
      if (angle &lt; 0)
          angle += 360;
      s.setRotation(angle * -1);
      return angle;
  }
  
  @Override
  public void render(float delta) {
      float angle;
      moveAlien();
      Gdx.gl.glClearColor(0, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
      world.step(Gdx.graphics.getDeltaTime(), 6, 2);
      angle = rotateMarine();
      rotateAlien(alien, spacemarine.getX(),
              spacemarine.getY());
      if (Gdx.input.isKeyPressed(Input.Keys.W) == true
              &amp;&amp; spacemarine.getY() &lt; 560) {
          Marinebody.setTransform(spacemarine.getX(), spacemarine.getY() + 4,
                  angle);
      }
      if (Gdx.input.isKeyPressed(Input.Keys.S) == true
              &amp;&amp; spacemarine.getY() &gt; 0) {
          Marinebody.setTransform(spacemarine.getX(), spacemarine.getY() - 4,
                  angle);
      }
      if (Gdx.input.isKeyPressed(Input.Keys.D) == true
              &amp;&amp; spacemarine.getX() &lt; 920) {
          Marinebody.setTransform(spacemarine.getX() + 4, spacemarine.getY(),
                  angle);
      }
      if (Gdx.input.isKeyPressed(Input.Keys.A) == true
              &amp; spacemarine.getX() &gt; 8) {
          Marinebody.setTransform(spacemarine.getX() - 4, spacemarine.getY(),
                  angle);
      }
      alien.setPosition(Alienbody.getPosition().x, Alienbody.getPosition().y);
      spacemarine.setPosition(Marinebody.getPosition().x, Marinebody.getPosition().y);
      batch.begin();
      spacemarine.draw(batch);
      alien.draw(batch);
      batch.end();
      // stage.act();
      // stage.draw();
  }
  </code></pre>