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/3389f4c5ffad6d562a4e to your computer and use it in GitHub Desktop.

Select an option

Save veeneck/3389f4c5ffad6d562a4e to your computer and use it in GitHub Desktop.
The squad class that holds our units.
import SpriteKit
import Foundation
class Squad : SKNode {
// Handle on all units in the squad.
var units : Array<CharacterNode> = []
// Current formation technique
var formation : Formation?
required init(coder aDecoder: (NSCoder!)) {
super.init(coder: aDecoder)
}
override init() {
super.init()
// Hard code a formation for this squad.
self.formation = Formation()
}
func addUnit(unit:CharacterNode) {
// Add unit to local array.
self.units.append(unit)
// Add unit to world as a child of this node.
self.addChild(unit)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment