Swift | XCode 7.3
I have two buttons in the MenuScene, which both are SKShapeNode
. I am using the touchesEnded function to check whether a button was pressed.
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
if let touch = touches.first {
let position = touch.locationInView(view)
if firstButton.containsPoint(position) {
let someScene = SomeScene(size: view!.bounds.size)
self.view?.presentScene(someScene)
} else if secondButton.containsPoint(position) {
let anotherScene = AnotherScene(size: view!.bounds.size)
self.view?.presentScene(anotherScene)
}
}
}
This worked just fine. However, when I changed the button’s position (not during the game, I deleted the old code and replaced it with a new one), something weird happened.
As the simulator presents the MenuScene, the buttons do not work. However, the old locations, which DOES NOT EXIST in my code, trigger the buttons.
I cannot see how the function can cause this to happen. I have tried restarting my computer, without luck. If you need more information, please let me know. In advance, thanks!