I am currently working on a Gumball Machine code wherein a coin should be inserted into the machine i.e a coin should be moved over the coin insertion area of the machine and as soon as the coin comes over that area, it should disappear. The problem I'm facing is that as soon as the coin comes over the area, it doesn't disappear rather it doesn't move from that point. I'm posting my code in the Coin class for reference:
public class Coin extends Actor
{
public void act()
{
int mouseX, mouseY ;
if(Greenfoot.mouseDragged(this)) {
MouseInfo mouse = Greenfoot.getMouseInfo();
mouseX=mouse.getX();
mouseY=mouse.getY();
setLocation(mouseX, mouseY);
}
//method to disappear the coin
disappear();
}
public void disappear()
{
Actor rcvCoin;
rcvCoin = getOneObjectAtOffset(380,280,Coin.class);
if (rcvCoin != null)
{
World world;
world = getWorld();
world.removeObject(rcvCoin);
world.removeObject(this);
return;
}
}
}
Also, I'm posting the image of the application for the reference:


