I am developing a game for tvOS in swift spritekit. There is a viewcontroller A which presents a SKScene B. I am forwarding the pressesBegan and pressesEnded from A to B.
pressesBegan is being called in A and forwarded to B but pressedEnded is not even called in A. Iam not getting why?
Below are the function implemented in A.
override func pressesEnded(presses: Set<UIPress>, withEvent event: UIPressesEvent?) {
if ((self.view as! SKView).scene?.isMemberOfClass(GameScene) == true){
let gameScene = (self.view as! SKView).scene as! GameScene
gameScene.pressesEnded(presses, withEvent: event)
}
}
override func pressesBegan(presses: Set<UIPress>, withEvent event: UIPressesEvent?) {
if ((self.view as! SKView).scene?.isMemberOfClass(GameScene) == true){
let gameScene = (self.view as! SKView).scene as! GameScene
gameScene.pressesBegan(presses, withEvent: event)
}
}
Just ran into this myself.
I believe what is going on is that if you override the method:
- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)eventAnd don't call super within the method somewhere:
[super pressesBegan:presses withEvent:event];pressedEnded is also never called.
I had a situation where sometimes pressesEnded was called and sometimes it wasn't, and that was the only difference I could spot.