我们如何使用Cocos2d显示UIViewController和UIView? [英] How we can show UIViewController and UIView by using Cocos2d?

查看:114
本文介绍了我们如何使用Cocos2d显示UIViewController和UIView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Cocos2d来创建一个iPhone应用程序。我使用了四种类型的类
like bellow -

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类。 p>

but how can i show FlipView and HelloController class through MenuLayer class.

推荐答案

如果你问如何将UIKit视图等附加到cocos2d-iphone项目,你只需要做: / p>

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆