51. func update() {
switch node.physicsBody!.velocity.dy {
case let dy where dy > 30.0:
node.zRotation = (3.14/6.0)
case let dy where dy < -100.0:
node.zRotation = -1*(3.14/4.0)
default:
node.zRotation = 0.0
}
}
66. class PipePair {
// class let kind = "PIPES" // class variables not yet supported
class var kind : String { get {return "PIPES"} }
private let gapSize: CGFloat = 50
private var pipesNode: SKNode!
private var finalOffset: CGFloat!
private var startingOffset: CGFloat!
86. func didBeginContact(contact: SKPhysicsContact!) {
//...
case BodyType.pipe.toRaw() | BodyType.bird.toRaw():
bird.pushDown()
case BodyType.ground.toRaw() | BodyType.bird.toRaw():
for actor in actors {
actor.stop()
}
let shakeAction = SKAction.shake(0.1, amplitudeX: 20)
screenNode.runAction(shakeAction)
91. override func didMoveToView(view: SKView) {
let textures = Textures.cave()
let bg = Background(textureNamed: textures.background).addTo(screenNode)
let te = Ground(textureNamed: textures.ground).addTo(screenNode)
bird = Bird(textureNames: textures.bird).addTo(screenNode)
let pi = Pipes(textureNames: textures.pipes).addTo(screenNode)