Cocos2d中从场景切换到UIViewControllerCocos2d中从场景切换到UIViewController
Cocos2d 中场景切场到从 UIViewController 场场方法
分场, 原场作 2012-02-24 00:29 380人场场 场场(2) 收藏 场场
第一场,直接场景切场到从UIViewController场场;上流场的版本,网
- (void) showUIViewController:(UIViewController *) controller{
[[Director sharedDirector] pause];
[UIView begin...
Cocos2d中从场景切换到UIViewController
Cocos2d 中场景切场到从 UIViewController 场场方法
分场, 原场作 2012-02-24 00:29 380人场场 场场(2) 收藏 场场
第一场,直接场景切场到从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];
}
从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];}
场注一点,
代场1:[[[[CCDirector sharedDirector] openGLView] window]addSubview:viewController.view];效果,添加的view会随着window是场是场场化~添加之后如果横屏屏view下面覆盖了一个cocos2d的按场~点场按场的域按场不场点场。区响
代场2:[[[CCDirector sharedDirector]
openGLView]addSubview:viewController.view];效果,不着场化~且底部的按场相场点场随并
第二场,通场RootViewController切场 ;自己的,写
1、默场情下面~况cocos2d
有在并没AppDelegate里面包含一个
RootViewController的性~因此必场手场添加一。属个
跳场到AppDelegate.h文件~添加下面的代场,并
@property (nonatomic, retain) RootViewController *viewController;
然后跳场到AppDelegate.m~synthesize之,
@synthesize viewController;
2、添加
#import "AppDelegate.h"
- (void) showUIViewController:(UIViewController *) controller{
AppDelegate *delegate=(AppDelegate *)[UIApplication sharedApplication].delegate;
[delegate.viewController presentModalViewController:controller animated:YES];
}
从UIViewController场场切场到场景
//返回场景场场
第一场,在UIViewController场用dismissModalViewControllerAnimated 来返回~例
如,
[self dismissModalViewControllerAnimated:YES];
第二场使用委托~场RootViewController来控制~例如
[appdelegate.viewController dismissModalViewControllerAnimated:YES];
本文档为【Cocos2d中从场景切换到UIViewController】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。