0

I try to get the starting Point and the Second Point of an CGPath in Swift. This is my Code:

    func updatePlayerStats(_ controller: CameraViewController) {
        let finalBagLocation = trajectoryView.finalBagLocation
        playerStats.storePath(self.trajectoryView.fullTrajectory.cgPath)
        trajectoryView.resetPath()
        let stats = gameManager.playerStats
        let paths = stats.throwPaths
        let frame = view.bounds
        print("path.bounding: ", paths.count)
        for path in paths {
            let trajectoryView = TrajectoryView(frame: frame)
            trajectoryView.translatesAutoresizingMaskIntoConstraints = false
                // Add each trajectoryView as subview to current view.
            view.addSubview(trajectoryView)
            // Add contraints to make sure trajectoryView is within the safe area.
            NSLayoutConstraint.activate([
                trajectoryView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor, constant: 0),
                trajectoryView.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor, constant: 0),
                trajectoryView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 0),
                trajectoryView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: 0)
            ])
            trajectoryView.addPath(path)

I want to get the first two values of "paths". Is there any way to return this ones?

Dávid Pásztor
  • 45,571
  • 9
  • 73
  • 100

0 Answers0