Cocos2d怎样使用原生态的控件
2012-11-08 19:09
218 查看
这个不难实现.只要你得到当前的视图,然后在这个视图上添加你想要的视图控件.
UIView *view=[[DirectorsharedDirector] openGLView];
新的cocos2d 2.0为
UIView *view=[[DirectorsharedDirector] view];
UIScrollView *scrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(260, 50, 150, 250)];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 50, 72, 103)];
scrollview.contentSize = CGSizeMake(150, 252);
imageView.image = [UIImage imageNamed:@"BtnVirus.png"];
[scrollview addSubview:imageView];
[[[CCDirector sharedDirector] view] addSubview:scrollview];
要移除
[scrollview removeFromSuperview];
移除添加进来控件的写法
UIView* object;
object.tag = kObjTag;
[[[[CCDirector sharedDirector]openGLView] window]addSubview:object];//添加
[[[[[CCDirector sharedDirector]openGLView] window]viewWithTag:kObjTag]removeFromSuperview];//根据tag值移除
UIView *view=[[DirectorsharedDirector] openGLView];
新的cocos2d 2.0为
UIView *view=[[DirectorsharedDirector] view];
UIScrollView *scrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(260, 50, 150, 250)];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 50, 72, 103)];
scrollview.contentSize = CGSizeMake(150, 252);
imageView.image = [UIImage imageNamed:@"BtnVirus.png"];
[scrollview addSubview:imageView];
[[[CCDirector sharedDirector] view] addSubview:scrollview];
要移除
[scrollview removeFromSuperview];
移除添加进来控件的写法
UIView* object;
object.tag = kObjTag;
[[[[CCDirector sharedDirector]openGLView] window]addSubview:object];//添加
[[[[[CCDirector sharedDirector]openGLView] window]viewWithTag:kObjTag]removeFromSuperview];//根据tag值移除
相关文章推荐
- 怎样在 Cocos2d里面使用 UITapGestureRecognizer来处理单击和双击
- Cocos2d-x常用控件使用方式.
- cocos2d-x相关控件的使用
- 怎样在WPF/XAML中使用Winform中的控件(如PictureBox)?
- 怎样在VS2013/MFC中使用TeeChart绘图控件
- Cocos2d-x UI开发之CCControlColourPicker控件类使用实例
- 在winform中使用WebBrowser控件时怎样去除IE的滚动条
- cocos2d-x-2.0新增加了几个UI控件,这里我介绍下常用的这几个UI控件(CCControlSlider、CCControlSwitch、CCControlColourPicker)使用方法
- cocos2d控件(1)-使用URL创建的Sprite
- 怎样使用Navigation Drawer控件?
- cocos2d-x-2.0新增加了几个UI控件,这里我介绍下常用的这几个UI控件(CCControlSlider、CCControlSwitch、CCControlColourPicker)使用方法
- 演示事件(Event)怎样使用以及怎样为用户控件添加一个事件(示例代码下载)
- Cocos2d-x UI开发之CCControlSwitch控件类使用实例
- 怎样优化cocos2d/x程序的内存使用和程序大小
- 怎样在 Cocos2d里面使用 UITapGestureRecognizer来处理单击和双击
- cocos2d-x 中使用的android控件详细说明之webview
- Cocos2d-x中控件CCControlStepper的使用
- 演示事件(Event)怎样使用以及怎样为用户控件添加一个事件(示例代码下载)
- VC中怎样使用列表控件
- 怎样解决kodak扫描控件,在xp下使用出错的问题?2000是没有问题的