A general class of spherical Newtonian self-similar solutions for a cold fluid – II. Solutions with gravity