Basically what I'm trying to do is make a simple football game where the user drags the football, and when they release it the ball should move towards the goals. This is the code I have so far:
The problem is that when I release the ball, it just stays there for a while before suddenly jumping towards the goals. Does anyone know a way that I can make the ball look like it is moving towards the goals?
Many thanks in advance.
public void act()
{
MouseInfo mouse = Greenfoot.getMouseInfo();
boolean s = false;
if(Greenfoot.mouseDragged(this))
{
this.setLocation(mouse.getX(), mouse.getY());
}
if(Greenfoot.mouseDragEnded(this))
{
s = true;
}
while (s == true)
{
Goals g = (Goals) getWorld().getObjects(Goals.class).get(0);
turnTowards(g.getX(), g.getY());
shoot();
if((this.getX() == g.getX()) && (this.getY() == g.getY()))
{
s = false;
}
}
}
public void shoot()
{
move(2);
}
}
