Develop in Swift build a bouncy ball game

I've been learning how to code swift with "Develop in Swift" by Apple, and it has been great! However, I have a problem, I made a function, and it gives me an error on lines 78, 80, and 121. Can someone explain my error? Thank you for your time.




var barriers: [Shape] = []





let ball = OvalShape(width: 40, height:40)

let barrierWidth = 300.0

let barrierHeight = 25.0



let barrierPoints = [

    Point(x:0, y:0),

    Point(x:0, y:barrierHeight),

    Point(x:barrierWidth, y:barrierHeight),

    Point(x:barrierWidth, y:0)

]



let barrier = PolygonShape(points:barrierPoints)



let funnelPoints = [

    Point(x:0, y:50),

    Point(x:80, y:50),

    Point(x:60, y:0),

    Point(x:20, y:0)

]

let funnel = PolygonShape(points:funnelPoints)



let targetPoints=[

    Point(x:10, y:0),

    Point(x:0, y:10),

    Point(x:10, y:20),

    Point(x:20, y:10)

]



let target = PolygonShape(points:targetPoints)



func setUpTarget(){

    target.position = Point(x:200, y:400)

    target.hasPhysics = true

    target.isImmobile = true

    target.isImpermeable = false

    target.fillColor = .yellow

    target.name = "Target"

    //target.isDraggable = false

    

    scene.add(target)

    

}





/*

The setup() function is called once when the app launches. Without it, your app won't compile.

Use it to set up and start your app.



You can create as many other functions as you want, and declare variables and constants,

at the top level of the file (outside any function). You can't write any other kind of code,

for example if statements and for loops, at the top level; they have to be written inside

of a function.

*/



fileprivate func setUpBall() {

    ball.position = Point(x: 250, y:400)

    scene.add(ball)

    ball.hasPhysics = true

    ball.fillColor = .blue

    ball.onCollision = ballCollided(with:)

    ball.isDraggable = false

    scene.trackShape(ball)

    ball.onExitedScene = ballExitedScene

    ball.onTapped = resetGame

    ball.bounciness = 0.6

}



fileprivate func addBarrier(at position: Point, width: Double, height: Double, angle: Double){

    //Add a barrier to the scene.

    let barrierPoints = [

        Point:(x: 0, y: 0),

        Point:(x: 0, y: height),

        Point(x: width, y: height),

        Point(x: width, y: 0)

    ]

    let barrier = PolygonShape(points:barrierPoints)

    barrier.append(barrier)

    

    barrier.position = Point(x:200, y:150)

    barrier.hasPhysics = true

    scene.add(barrier)

    barrier.isImmobile = true

    barrier.angle = 0.1

}



fileprivate func setUpFunnel() {

    //Adds a funnel to the scene

    funnel.position = Point(x:200, y:scene.height - 25)

    scene.add(funnel)

    funnel.onTapped = dropBall

    funnel.isDraggable = false

}



func ballCollided(with otherShape: Shape){

    if otherShape.name != "Target"{return}

    

    otherShape.fillColor = .green

}



func ballExitedScene (){

    barrier.isDraggable = true

}



func resetGame (){

    ball.position = Point(x:0, y:-80)

}



func printPosition(of shape: Shape){

    print(shape.position)

}



func setup() {

    

    setUpBall()

    

    addBarrier()

    

    setUpFunnel()

    

    setUpTarget()

    

    resetGame()

    

    scene.onShapeMoved = printPosition(of:)

    

    

}



func dropBall() {

    ball.position = funnel.position

    ball.stopAllMotion()

    barrier.isDraggable = false

}

on lines 78, 80, and 121 What are lines 78, 80 and 121? Can someone explain my error? Can you show us the error you get?

Develop in Swift build a bouncy ball game
 
 
Q