i want to have it so that when the mouse is hovering over Button5 the button adds a Barrier to the location 497, 205. please help
// add instance field
private boolean isHovering; // default is false
// in act or method it calls
if (!isHovering && Greenfoot.mouseMoved(this) && getWorld().getObjectsAt(497, 205, Barrier.class).isEmpty())
{
isHovering = true;
getWorld.addObject(new Barrier(), 497, 205);
}
if (isHovering && !Greenfoot.mouseMoved(this))
{
isHovering = false;
// add the following if barrier disappears when mouse no longer hovers over button
getWorld().removeObjects(getWorld().getObjectsAt(497, 205, Barrier.class));
}