Time-varying formation control for second-order swarm systems with switching directed topologies