Hi, I'm making a board game style with already set coordinates as the board spaces. When a question is answered, they go to a space on the board, whether forwards or backwards (the spaces are not set up in a grid). Here is my method within the Actor class: (please let me know if you would like me to post any other pieces of code)
Ideally, I would like to find a way to animate the setLocation() method to see the character traveling between spaces. If this is not possible, what's the workaround? My idea was to find the distance between the two points, make a for loop to move(1), and then set the rotation back to zero. However, because the turn and move axis is not the center, I'm having trouble lining my actor up. Any help would be appreciated, thank you in advance!
public void moveTo(int pos)
{
int x; int y;
if (position == 0) {x = 100; y = 150;}
else if (position == 1) {x = 703; y = 107;}
else if (position == 2) {x = 989; y = 155;}
else if (position == 3) {x = 1246; y = 114;}
else if (position == 4) {x = 1161; y = 438;}
else if (position == 5) {x = 848; y = 351;}
else if (position == 6) {x = 501; y = 351;}
else if (position == 7) {x = 189; y = 546;}
else {x = 771; y = 567;} //final or win
int distance = (int) Math.sqrt((super.getY() - y) * (super.getY() - y) + (super.getX() - x) * (super.getX() - x));
turnTowards(x,y);
move(distance); //create loop
setRotation(0);
}
