 
 import SpriteKit
 
-class GameScene: SKScene {
+class GameScene: SKScene, SKPhysicsContactDelegate {
+    
+    var initPostision: CGPoint?
+    let CATEGORY_RACKET: UInt32 = 0x00000001
+    let CATEGORY_BALL: UInt32 = 0x00000010
     
     // not supported construct.
     required init(coder aDecoder: NSCoder) {

    
    // Draw racket image.
    private func drawRacket() {
        let image = SKSpriteNode(imageNamed: "racket.png")
        image.size.width *= 0.3
        image.size.height *= 0.3
        image.position = CGPointMake(self.frame.size.width / 2, self.frame.size.height / 3)
        image.physicsBody = SKPhysicsBody(rectangleOfSize: image.size)
        image.name = "racket"
        self.addChild(image)
    }
    
    override func didMoveToView(view: SKView) {
        self.physicsBody = SKPhysicsBody(edgeLoopFromRect: self.frame)
        self.physicsWorld.gravity = CGVectorMake(0.0, -5.0)
        

            var isRacket = false
            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)
                        isRacket = true
                    }
                }
