我怎样才能改变我的程序,让这个对象只对一次触摸做出反应?

How can i alter my program to allow this object to only react to a single touch?

我正在制作篮球比赛。我的问题是当我射球时,我可以再次在半空中触球,这是我不想要的。一旦用户射出球,我不希望触摸产生影响。这是我的代码:

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?
{
    touching = false
    for touch: AnyObject in touches {
    let location = touch.locationInNode(self)
    if ball.frame.contains(location){
        touchingPoint = location
        touching = true
    }
    }
}


override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
    for touch: AnyObject in touches {
    let location = touch.locationInNode(self)
        touchingPoint = location
    }
}


override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
    if touching{
        let dt:CGFloat = 8.25/29.5
        let distance = CGVector(dx: touchingPoint.x-ball.position.x, dy: touchingPoint.y-ball.position.y)
        let velocity = CGVector(dx: distance.dx/dt, dy: distance.dy/dt)
        ball.physicsBody!.velocity=velocity
    }
}

我可以在我的程序中添加什么,以便在球被射出后触摸不会有任何效果?

投篮后禁用用户交互

ball.userInteractionEnabled = false

然后在您希望他们能够触摸它时再次启用它