cocos2d场景和UIViewController视图的切换

原地址http://mcgtts.iteye.com/blog/1140000

cocos2d中从场景切换到UIViewController视图
- (void) showUIViewController:(UIViewController *) controller  
{  
    [[Director sharedDirector] pause];  
      
    [UIView beginAnimations:nil context:NULL];  
    [UIView setAnimationDuration:.5];  
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:[[Director sharedDirector] openGLView] cache:YES];  
      
    [[[Director sharedDirector] openGLView] addSubview:controller.view];  
      
    [UIView commitAnimations];  
}  

cocos2d中从UIViewController视图切换到场景
//返回场景视图  
- (void) hideUIViewController:(UIViewController *) controller  
{  
    [UIView beginAnimations:nil context:NULL];  
    [UIView setAnimationDuration:.5];  
    [UIView setAnimationDelegate:self];  
    [UIView setAnimationDidStopSelector:@selector(animDone:finished:context:)];  
      
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:[[Director sharedDirector] openGLView] cache:YES];  
      
    [controller.view removeFromSuperview];  
      
    [UIView commitAnimations];  
}  
  
-(void)animDone:(NSString*) animationID finished:(BOOL) finished context:(void*) context  
{      
    [[Director sharedDirector] resume];  
} 

你可能感兴趣的:(cocos2d)