Explained in my blog post HTML5 Space Invaders with box2dweb Physics