如何使用 Cocos2d 显示 UIViewController 和 UIView?

How we can show UIViewController and UIView by using Cocos2d?(如何使用 Cocos2d 显示 UIViewController 和 UIView?)

本文介绍了如何使用 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?

基础教程推荐