Reputation: 5795
I have an SKScene and I present another scene in it. Here is the code for presentation:
[self.view presentScene:[[LoseScene alloc] initWithSize:self.size] transition:[SKTransition crossFadeWithDuration:1.5]];
Here is my init code for lose scene:
-(id)initWithSize:(CGSize)size {
if (self = [super initWithSize:size]) {
// code omitted
}
return self;
}
Problem is that this method in LoseScene is never getting called:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
Upvotes: 2
Views: 1003
Reputation: 222
It seems like you got it working but if anyone else is running into this issue I figured out what can cause weird behavior. A lot of issues can arise if you happen to call presentScene too many times. This can happen if presentScene is in the update method.
- (void)update:(NSTimeInterval)currentTime {
[self.view presentScene:myScene transition: reveal];
}
The view is constantly presenting the scene which will cause all sorts of things to break. Make sure this only gets called once when you want to present the scene and things should work fine. A simple flag would do.
- (void)update:(NSTimeInterval)currentTime {
if(_gameOver) {
[self.view presentScene:myScene transition: reveal];
_gameOver = NO;
}
}
Upvotes: 1