0

I don't understand why my doesn't work.

Use case :

  1. Test 1: I launch game, i click on Play button (presentScene) from the first Scene, So i go to second scene. No problem.
  2. 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;
        }
    }
}
4

1 回答 1

0

现在好啦!

我已将通知替换为来自菜单场景的呼叫:

if ([_buttonParam containsPoint:[touch locationInNode:_buttonParam.parent]])
    {
        //[[NSNotificationCenter defaultCenter] postNotificationName:kNotificationShowParam object:nil];
        [self.view.window.rootViewController presentViewController:_paramController animated: YES completion:^(void) {
            SKView * skView = (SKView *)self.view;
            MyScene *MenuScene = [[MyScene alloc]initWithSize:skView.bounds.size];
            MenuScene.scaleMode = SKSceneScaleModeAspectFill;
            [skView presentScene:MenuScene];
        }];
        break;
    }

这样,我可以在完成后找到原始控制器。

于 2014-03-18T11:41:46.880 回答