cocos2d场景和UIViewController视图的切换

来源:互联网 发布:生化危机5知乎 编辑:程序博客网 时间:2024/06/16 19:52


cocos2d中从场景切换到UIViewController视图

Cpp代码  收藏代码
  1. - (void) showUIViewController:(UIViewController *) controller  
  2. {  
  3.     [[Director sharedDirector] pause];  
  4.       
  5.     [UIView beginAnimations:nil context:NULL];  
  6.     [UIView setAnimationDuration:.5];  
  7.     [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:[[Director sharedDirector] openGLView] cache:YES];  
  8.       
  9.     [[[Director sharedDirector] openGLView] addSubview:controller.view];  
  10.       
  11.     [UIView commitAnimations];  
  12. }  

 cocos2d中从UIViewController视图切换到场景

Cpp代码  收藏代码
  1. //返回场景视图  
  2. - (void) hideUIViewController:(UIViewController *) controller  
  3. {  
  4.     [UIView beginAnimations:nil context:NULL];  
  5.     [UIView setAnimationDuration:.5];  
  6.     [UIView setAnimationDelegate:self];  
  7.     [UIView setAnimationDidStopSelector:@selector(animDone:finished:context:)];  
  8.       
  9.     [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:[[Director sharedDirector] openGLView] cache:YES];  
  10.       
  11.     [controller.view removeFromSuperview];  
  12.       
  13.     [UIView commitAnimations];  
  14. }  
  15.   
  16. -(void)animDone:(NSString*) animationID finished:(BOOL) finished context:(void*) context  
  17. {      
  18.     [[Director sharedDirector] resume];  


原创粉丝点击