 import AVFoundation
 
 class GameScene: SKScene, SKPhysicsContactDelegate {
-
+    
     var hero = SKSpriteNode()
     var road = SKSpriteNode()
     // Factor to set entry X position for hero

        playButton.zPosition = 5
        self.addChild(self.playButton)
    }
  
  //kori/brian
  func spawnCrane(){
    var randX = arc4random_uniform(300) + 100
    let craneHook = SKSpriteNode(imageNamed: "crane.gif")
    let chain = SKSpriteNode(imageNamed: "chain.png")
    let contactNode = SKSpriteNode()
    
    
    chain.anchorPoint = CGPointMake(1.0, 1.0)
    chain.position = CGPointMake((CGRectGetMaxX(self.frame) + CGFloat(randX)), CGRectGetMaxY(self.frame))
    chain.size = CGSize(width: 10, height: 420)
    chain.name = "chain"
    
    craneHook.anchorPoint = CGPointMake(1.0, 1.0)
    craneHook.position = CGPointMake((CGRectGetMaxX(self.frame) + CGFloat(randX) + 45),
      CGRectGetMaxY(self.frame) * 0.38)
    craneHook.physicsBody = SKPhysicsBody(rectangleOfSize: CGSize(width: 130, height: 165))

    craneHook.zPosition = 12
    craneHook.physicsBody?.dynamic = false
    craneHook.size = CGSize(width: 100.0, height: 100.0)
    craneHook.name = "craneHook"
    
    contactNode.size = CGSize(width: 130, height: 165)
    contactNode.position = CGPointMake((CGRectGetMaxX(self.frame) + CGFloat(randX) + 40),
      CGRectGetMaxY(self.frame) * 0.38)
    contactNode.physicsBody?.categoryBitMask = UInt32(self.obstacleCategory)
    contactNode.physicsBody?.contactTestBitMask = UInt32(self.heroCategory) | UInt32(self.obstacleCategory)

    addChild(contactNode)
    self.addChild(chain)
    self.addChild(craneHook)
    
    
//    craneHook.anchorPoint = CGPointMake(1.0, 1.0)
//    craneHook.position = CGPointMake(CGRectGetMaxX(self.frame) + CGFloat(randX),
//      CGRectGetMaxY(self.frame))
//    craneHook.physicsBody = SKPhysicsBody(rectangleOfSize: CGSize(width: 60, height: 100))
//    craneHook.physicsBody?.dynamic = false
//    craneHook.size = CGSize(width: 60.0, height: 100.0)
//    craneHook.name = "craneHook"
//    self.addChild(craneHook)

  }

    func createMenuButton() {
        menuButton.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame) + 30 )
        menuButton.zPosition = 5

    
    func didBeginContact(contact: SKPhysicsContact) {
        println("Contact occured")
        //        println("bodyA is \(contact.bodyA.node?.name) ")
        //        println("bodyB is \(contact.bodyB.node?.name) ")
        let contactMask = contact.bodyA.categoryBitMask | contact.bodyB.categoryBitMask
        switch contactMask {
        case UInt32(self.heroCategory) | UInt32(self.groundCategory):
