I'm trying to move my pieces so that when I click on a piece I get its x and y coordinates so that I will be able to click on a spot on the board and move it to that spot after.
Here is what I have so far:
public boolean selectPiece()
{
MouseInfo mouse = Greenfoot.getMouseInfo();
int x = 0;
int y = 0;
if(mouse != null) //if the mouse if pressing on something
{
Actor piece = mouse.getActor();
isSelected_ = true;
if(isSelected_ == true && Greenfoot.mouseClicked(piece))
{
x = piece.getX();
y = piece.getY();
}
}
}
public void movePiece()
{
MouseInfo mouse = Greenfoot.getMouseInfo();
if(selectPiece())
{
if(isSelected_ == true && Greenfoot.mouseClicked(this))
{
int fx = mouse.getX();
int fy = mouse.getY();
//piece.setLocation(fx, fy);
}
}
}
