Skip to content

Instantly share code, notes, and snippets.

@veeneck
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save veeneck/887215255fbaf954eddc to your computer and use it in GitHub Desktop.

Select an option

Save veeneck/887215255fbaf954eddc to your computer and use it in GitHub Desktop.
Move into formation function.
func moveIntoFormation() {
// Loop over each unit in our Squad.
for (i, unit) in enumerate(self.units) {
// Get the vector from the formation class for that position.
// Just a simple accessor to the array.
let vector = self.formation!.getVectorAtPosition(i)
// Make a CGPoint from that vector, and tell the unit to walk to it.
let position = CGPoint(x:vector.dx, y:vector.dy)
unit.moveToPoint(position, callback: {
// clean up post animation
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment