福州网站大全,seo营销策略,如何建立一个私人网站,网站开发和系统开发的区别cocos2d是使用继承于ccnode的结点类型的层。但是我想用一个opengl来绘制#xff0c;就简单的情况来说必须得加一个uiview。现转载如下#xff1a; 第一部分#xff1a;#xff1a; 使用Cocos2D开发游戏和应用程序的时候#xff0c;时常有些功能用系统控键很容易就实现就简单的情况来说必须得加一个uiview。现转载如下 第一部分 使用Cocos2D开发游戏和应用程序的时候时常有些功能用系统控键很容易就实现而cocos2d很麻烦这时候就需要在cocos2D的程序中添加UIView或者UIView的子类。如果需要响应重力感应来支持旋转可以向cocos2d程序中添加UIViewController的子类。 方法很简单 [[[CCDirector sharedDirector] openGLView] addSubview:[UIView view]]; 第二部分转自人人目前看不太懂以后应该用的到 Cocos2d中对UIView的使用 Cocos2d中想使用UIView等UIKit系的控件最常用常见的方法就是通过openGLView来做虽然这个非常简单还是简述下吧。 比如现在我想在cocos2d中使用UIImageView这个控件非常简单直接上代码。 CGRect frame [[[CCDirector sharedDirector] openGLView] frame];_animateImageView [[UIImageView alloc] initWithFrame:frame];[[[CCDirector sharedDirector] openGLView] addSubview:_animateImageView]; 不用了的时候。 [_animateImageView release];[_animateImageView removeFromSuperview]; 诺这样呢有一个问题使用的UIImageView若不remove掉的话总是显示在最上面再加个Sprite啥的也加不上去。恰好这次需要的图比较大320*480还想借助UIImageView的动画功能这下郁闷了。 怎么样才能即能让他顺利展示又能再上面添加Sprite或者CCMenu等呢。 OK, 直接给出解决方案吧。因为一旦采用openGLView addSubView的话肯定是不行的那一个解决思路是在openGLView下插入一层View, 同时把openGLView设置成透明的这样不就行了。 代码如下首先要动的是AppDelegate在openGLView下加入一层。 //Set glView by wordsworth Mar.26 [glView setMultipleTouchEnabled:YES];glView.opaque NO;glClearColor(0.0f, 0.0f, 0.0f, 0.0f);glClear(GL_COLOR_BUFFER_BIT); //add a view by wordsworth Mar.26, in order to insert another view in MainBoardLayer overView [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];overView.opaque NO;overView.backgroundColor [UIColor clearColor];[overView addSubview:glView];[window addSubview:overView]; 最后把我们的ImageView尽情的写入openGLView下面吧这样在上面加上各种各样的CCSprite、CCMenu等不用担心不显示啦。 AppDelegate * delegate (AppDelegate *)[[UIApplication sharedApplication] delegate];[delegate.overView insertSubview:_animateImageView belowSubview:[[CCDirector sharedDirector] openGLView]]; 其他的UIKit控件也差不多可以按这个套路来了。 转载于:https://www.cnblogs.com/baozou/p/3273437.html