I’m making an android game in E3roid I’m attempting to rotate the sprite with the analog stick then have the sprite move in the direction that the ship is facing. Here is the code I used the set the angle.
double angleRadians = Math.atan2(sprite.getRealY() - relativeX,sprite.getRealX() - relativeY);
double angleDegrees = Math.toDegrees(angleRadians);
double angle = -1 * angleDegrees;
sprite.rotate((float)angle);
How would I move the sprite in the same direction as the angle?
do I convert the angle back into Radians?
sprite.move(int,int);
Thanks if you help me!
You can think of your angle as the hypotenuse of a right triangle. To move your sprite a certain number of pixels up and right, you need to use geometry to figure out how many pixels that is. sin and cos should do the trick. If you have forgotten your geometry