ベジェ曲線を作成し、オブジェクトの衝突境界を作成します。私は適切な衝突を作成することはできませんように私はこの2回の試行でaddArcWithCenteベジェパスを閉じるのを防ぐにはどうすればいいですか?
line.moveToPoint(firstSurfacePoint)
line.addArcWithCenter(center, radius: radius, startAngle: CGFloat(M_PI), endAngle: CGFloat(M_PI/2), clockwise: false)
line.addLineToPoint(fourthSurfacePoint)
を選択した場合、私は、取得
let firstSurfacePoint = CGPoint(x: 30, y: 120)
let secondSurfacePoint = CGPoint(x: 20, y: 200)
let thirdSurfacePoint = CGPoint(x: 200, y: 300)
let center = CGPoint(x: 150, y: 120)
let radius: CGFloat = 120.00
let arcWidth: CGFloat = 20.00
let fourthSurfacePoint = CGPoint(x: 240, y: 300)
func createCollisionPath(collision: UICollisionBehavior) {
let line = UIBezierPath()
line.moveToPoint(firstSurfacePoint)
line.addCurveToPoint(thirdSurfacePoint, controlPoint1: secondSurfacePoint, controlPoint2: secondSurfacePoint)
line.addLineToPoint(fourthSurfacePoint)
let currentPath = CAShapeLayer()
currentPath.path = line.CGPath
currentPath.strokeColor = UIColor.blackColor().CGColor
currentPath.fillColor = UIColor.clearColor().CGColor
currentPath.lineWidth = 1
view.layer.addSublayer(currentPath)
collision.addBoundaryWithIdentifier("curve", forPath: line)
}
同じ貧しい結果が、重要である奇妙な結果を受け取ります。最初の試みでは、オブジェクトは、最初の点から3番目の点までの直線と同様に、パスを通ります。
何が間違っていますか?
働いていたではなく、私は疑うようhttp://stackoverflow.com/q/40756457/2303865 –