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?


- android 4中的android RadioButton问题 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01