Energetic efficiency and gait transition of legged animals