-2

I am making an ios game with a moving character and a rotating weapon, it worked but then I took a month break and ios got an update to 9. My code no longer works and gives me an error. What is the error and more importantly how do I go about fixing it?

 override func touchesMoved(touches: Set<NSObject>, withEvent event: UIEvent) {
    for touch in (touches as! Set<UITouch>) {
        let location = touch.locationInNode(self)
        if (leftButton.containsPoint(location)){
            leftPressed = true
        }else{
            leftPressed = false
        }
        if (rightButton.containsPoint(location)){
            rightPressed = true
        }else{
            rightPressed = false
        }
    }
}

That is one of my code snippets that gets the error. Here is the error: Method does not override any method from its superclass

1 Answers1

0

What likely happened is that during the update to iOS 9, the function changed and your implementation is outdated and no longer valid.

Read the documentation here (already at the function you are using).

You defined your function as

touchesMoved(touches: Set<NSObject>, withEvent event: UIEvent)

The new implementation is

touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?)

Your implementation takes a different data type as an argument and is therefore not the same function and this is why you are getting the override error.

Arc676
  • 4,445
  • 3
  • 28
  • 44