cocos2d场景和UIViewController视图的切换

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];
}
posted @ 2011-08-23 13:12  痴人指路  阅读(388)  评论(0编辑  收藏  举报