I don't understand why my doesn't work.
Use case :
- Test 1: I launch game, i click on Play button (presentScene) from the first Scene, So i go to second scene. No problem.
- Test 2: I launch game, i click on Option button (presentViewController) from the first Scene. On Optin controller, i click to dismissViewControllerAnimated. If i want click on Play button, there is no change on screen but the game is plain behind. I don't understand why the scene stay on screen and why there is no transition.
There is no error output.
Code Controller:
- (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showParam) name:kNotificationShowParam object:nil];
//...
SKView * skView = (SKView *)self.view;
SKScene * scene = [[MenuScene alloc ]initWithSize:skView.bounds.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
[skView presentScene:scene];
}
- (void)showParam
{
ParamViewController *ParamView = [[crazyButterflyParamViewController alloc]init];
[self presentViewController: ParamView animated: YES completion:^ {
}];
}
Code ParamController:
//method on button
-(void)goToMenu
{
[self.view.window.rootViewController dismissViewControllerAnimated:YES completion:^{
}];
}
Code MenuScene:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch* touch in touches)
{
if ([_button containsPoint:[touch locationInNode:_button.parent]])
{
SKTransition *transition = [SKTransition fadeWithDuration:0.4];
SKScene *scene = [[GameScene alloc] initWithSize:self.size];
scene.scaleMode = SKSceneScaleModeAspectFill;
[self.scene.view presentScene:scene transition:transition];
break;
}
if ([_buttonParam containsPoint:[touch locationInNode:_buttonParam.parent]])
{
[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationShowParam object:nil];
break;
}
}
}