I am trying to make the different rows of foosball men slide up and down based on the mouse's distance from the table center, so the mouse doesn't go out of the stage.
At the moment I calculate the row position using:
newY = mouseY - center;
if (newY < top) y = top;
else if (newY > bottom) y = bottom;
else y = newY;
The problem is: When the wider rows reach their edge the smaller rows carry on going. So when you move the mouse back down there is a delay before the wider rows start moving.
I want it so when a row reaches it's edge it will go down as soon as you move the mouse back, but I want the position to be calculated from the center. I've been trying to figure out a way, but all I have managed to do is break my code....
Any help greatly appreciated