views:

211

answers:

0

I have a added a navigation controller's view in application's main window using,

[window addSubview:[navController view]];

I have also one push notification,

NSNotificationCenter *theNotificationCenter = [NSNotificationCenter defaultCenter];
[theNotificationCenter addObserver:self selector:@selector(showSelf:) name:@"showHomeMenu" object:nil];

And the respective method,

-(void)showSelf:(NSNotification *)inNotification{
    [self.navController popToViewController:self animated: YES];
}

Now in the navController, I have other navigation controller which is being pushed on clicking of its navigation bar's button. That navigation controller is also having same scenario.

At one point, on clicking navigation bar's button, I am adding cocos2d layer using,

[[Director sharedDirector] setAnimationInterval:1.0/60];
[Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888];
[[Director sharedDirector] attachInView:[appDelegate window]];
Scene *scene=[Scene node];
MainScreen *layer=[MainScreen node];
[scene addChild:layer];
[[Director sharedDirector] runWithScene:scene];

And the game starts, At the finishing of game I have the following code,

[[UIApplication sharedApplication] setIdleTimerDisabled:NO];
[[Director sharedDirector]stopAnimation];
[[Director sharedDirector] end];
[[NSNotificationCenter defaultCenter] postNotificationName: @"showHomeMenu" object:nil];

So, when notification call my main menu is appearing.

Upto this is ok.

Now, from main menu once again I am navigaing through the application and controller by controller, and I am reaching the game main screen by the code as above,

[[Director sharedDirector] setAnimationInterval:1.0/60];
[Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA8888];
[[Director sharedDirector] attachInView:[appDelegate window]];
Scene *scene=[Scene node];
MainScreen *layer=[MainScreen node];
[scene addChild:layer];
[[Director sharedDirector] runWithScene:scene];

At this moment the game is started, but my screen is not being updated. Means, the screen is struck ed at the same position when the game was finished and the main menu was displayed.

Game is going perfect, means all the events is happening. I can say this because the music is correct and at same point it is finished as well. The main problem is the screen which is not being updated and it is showing the last state of the previous game play.

If I close the application and start again on the first navigation it will run perfect, but by coming to main menu and again navigating through and coming to game point the same problem occurs as described above.

Any idea for this problem?