How we can show UIViewController and UIView by using Cocos2d?(如何使用 Cocos2d 显示 UIViewController 和 UIView?)
问题描述
我正在尝试使用 Cocos2d 构建一个 iPhone 应用程序.但是我使用了四种类型的类像下面这样-
I am trying to build an iPhone app by using Cocos2d.But i have used four types of classes like bellow-
@interface MenuScene : Scene {}
@end
@interface FlipView : UIImageView
{
CGPoint startTouchPosition;
NSString *dirString;
UIImageView *firstPieceView;
UIImageView *secondPieceView;
}
@end
@interface HelloController : UIViewController
@end
@interface MenuLayer: Layer{
Todo *todo;
Menu * menu;
sqlite3 *database;
NSMutableArray *todos;
NSString *dirString;
CGPoint startTouchPosition;
}
@property (nonatomic, retain) NSMutableArray *todos;
-(void) button1: (id)sender;
-(void) button2: (id)sender;
-(void) black_jack: (id)sender;
@end
但是如何通过 MenuLayer 类显示 FlipView 和 HelloController 类.
but how can i show FlipView and HelloController class through MenuLayer class.
推荐答案
如果你问如何将 UIKit 视图等附加到 cocos2d-iphone 项目,你只需要这样做:
If you are asking how to attach UIKit views and such to a cocos2d-iphone project, you just have to do it like:
[[[Director sharedDirector] window] addSubview:myView];
更新到 cocos 0.7,现在是:
Updated to cocos 0.7 and now this is:
[[[Director sharedDirector] openGLView] addSubview:myView];
在 Cocos 0.99 中:
And in Cocos 0.99:
[[[CCDirector sharedDirector] openGLView] addSubview:myView];
在 Cocos 2.0 中
And in Cocos 2.0
[[[CCDirector sharedDirector] view] addSubview:myView];
这篇关于如何使用 Cocos2d 显示 UIViewController 和 UIView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 Cocos2d 显示 UIViewController 和 UIView?


基础教程推荐
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01