I wan't my sprite to point at the cursor, how do I compute on how much do I need to rotate it?
//First is get the cursor position
x=Gdx.input.getX();
y=Gdx.input.getY();
//then rotate the sprite and make it point where the cursor is
Sprite.rotate(??);
update--> I tried this but I don't know what should be the condition to make it stop rotating when is already pointed at the right direction
double radians = Math.atan2(mouseY - spriteY, mouseX - spriteX)
float fl=(float)radians;
Sprite.rotate(fl)
update 2--> It barely moves when I do this:
public void update(){
int x=Gdx.input.getX();
int y=Gdx.input.getY();
double radians=Math.atan2(y-Spr.getY(),x-Spr.getX());
float angle=(float)radians;
Spr.setRotation(angle);
}
update 3 --> So now I think it's following the cursor but it uses the opposite part of the sprite, Imagine an arrow instead of pointing using the pointy part of the arrow it uses the opposite side of the arrow, hope you understand what I mean, btw this is what I did instead:
public void update(){
int x=Gdx.input.getX();
int y=Gdx.graphics.getHeight()-Gdx.input.getY();
double radians= Math.atan2(y - launcherSpr.getY(), x - launcherSpr.getX());
float angle=(float)radians*MathUtils.radiansToDegrees; //here
launcherSpr.setRotation(angle);
}