             self.sequence = .GAME
             self.drawRacket()
             self.setUiLayer()
+            self.addBall(CGPointMake(self.frame.width / 2, self.frame.height - 10))
         })
     }
     
     func didBeginContact(contact: SKPhysicsContact) {
-        print("didBeginContact")
-        uiLayerView!.pointup(1) // TODO fix point value.
+        
+        let mask = contact.bodyA.categoryBitMask | contact.bodyB.categoryBitMask
+        if mask == (CATEGORY_RACKET | CATEGORY_BALL) {
+            uiLayerView!.pointup(1) // TODO fix point value.
+        } else if mask == (CATEGORY_ROUND | CATEGORY_BALL) {
+            print("finish")
+        }
+        
     }
     
     override func update(currentTime: CFTimeInterval) {

        self.physicsWorld.contactDelegate = self
        self.physicsBody = SKPhysicsBody(edgeLoopFromRect: self.frame)
        self.physicsWorld.gravity = CGVectorMake(0.0, -5.0)
        
        drawBackground()
    }

        for touch: AnyObject in touches {
            let location = touch.locationInNode(self)
            
            for r in self.children {
                if r.name == "racket" {
                    if location.y < ((self.size.height * 2) / 3) {
                        let seq = SKAction.sequence([SKAction.moveTo(location, duration: 0.25),
                            SKAction.moveTo(initPostision!, duration: 0.5)])
                        r.runAction(seq)
                    }
                }
            }
        }
    }
