Not vector but physics really. You seem to understand vectors just fine, it's just that if an object doesn't generate any friction it will never stop. Well here we go:
Unless the ball is in a vacuum, it generates friction by rubbing against the air or whatever gas it is in. This is considerably less friction then rubbing against a solid wall, but friction none the less.PHP Code:// enterframe function
function onFrame(e:Event):void
{
movement.y += 0.8;
ballDist.x = bigBall.x - smallBall.x;
ballDist.y = bigBall.y - smallBall.y;
// if the smaller ball is outside the bigger ball
// perform reaction
if(ballDist.len+smallBall.width/2 > bigBall.width / 2)
{
(....)
//Friction is applied
movement.x *= 0.5;
movement.y *= 0.5;
/*if(movement.len < 0.4) //This is still quite a big number. I'd go with a value like < 0.000001
{
movement.x = 0;
movement.y = 0;
}*/
} else {
//Friction is applied
movement.x *= 0.95;
movement.y *= 0.95;
}
smallBall.x+=movement.x;
smallBall.y+=movement.y;
}





Reply With Quote