Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cocos2d iphone 在openGLView-cocos2d iphone的桌面上添加CCLabel_Cocos2d Iphone - Fatal编程技术网

Cocos2d iphone 在openGLView-cocos2d iphone的桌面上添加CCLabel

Cocos2d iphone 在openGLView-cocos2d iphone的桌面上添加CCLabel,cocos2d-iphone,Cocos2d Iphone,因此,在CCLayer中,我在openGLView中添加了一个ImagePicker/Camera,然后添加了一个UIButton——这一切都很好,但现在我想在这些元素上添加一个CCLabel(以及将来的CCSprites) uip = [[UIImagePickerController alloc] init]; uip.sourceType = UIImagePickerControllerSourceTypeCamera; uip.showsCameraContro

因此,在CCLayer中,我在openGLView中添加了一个ImagePicker/Camera,然后添加了一个UIButton——这一切都很好,但现在我想在这些元素上添加一个CCLabel(以及将来的CCSprites)

    uip = [[UIImagePickerController alloc] init];
    uip.sourceType = UIImagePickerControllerSourceTypeCamera;
    uip.showsCameraControls = NO;
    uip.toolbarHidden = YES;
    uip.navigationBarHidden = YES;
    uip.wantsFullScreenLayout = YES;
    uip.cameraViewTransform = CGAffineTransformScale(uip.cameraViewTransform, CAMERA_TRANSFORM, CAMERA_TRANSFORM);

    [[[CCDirector sharedDirector] openGLView] addSubview:uip.view];

    arrowButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [arrowButton addTarget:self 
               action:@selector(arrowButtonClicked:)
     forControlEvents:UIControlEventTouchUpInside];

    UIImage *imgNormal = [UIImage imageNamed:@"btn_next_norm.png"];
    [arrowButton setImage:imgNormal forState:UIControlStateNormal];

    UIImage *imgPressed = [UIImage imageNamed:@"btn_next_pressed.png"];
    [arrowButton setImage:imgPressed forState:UIControlStateHighlighted];

    arrowButton.frame = CGRectMake(screenSize.width - 48.0, screenSize.height - 37.0, 48.0, 37.0);

    [[[CCDirector sharedDirector] openGLView] addSubview:arrowButton];

    CCLabelTTF* label = [CCLabelTTF labelWithString:@"Experience 1" fontName:@"Arial" fontSize:32];
    label.color = ccc3(0, 0, 0);
    CGSize size = [[CCDirector sharedDirector] winSize];
    label.position = CGPointMake(size.width / 2, size.height / 2);
   // [[[CCDirector sharedDirector] openGLView] addSubview:labe]; cant add to openGLView

您需要在openGLView下添加子视图UIView组件,如下所示:

[[[CCDirector sharedDirector] openGLView].superview addSubview:arrowButton];
然后,openGLView应该是透明的。“”

编辑:

移动UIImagePickerController顶部的COCO

好的,下面的呢?添加子视图UIImagePickerController的cameraOverlayView上的cocos2d视图(openGLView)

[[[CCDirector sharedDirector] openGLView].superview addSubview:uip.view];
[[[[CCDirector sharedDirector] openGLView] removeFromSuperview];
uip.cameraOverlayView = [[CCDirector sharedDirector] openGLView];

另外,您需要。

您需要在openGLView下添加子视图UIView组件,如下所示:

[[[CCDirector sharedDirector] openGLView].superview addSubview:arrowButton];
然后,openGLView应该是透明的。“”

编辑:

移动UIImagePickerController顶部的COCO

好的,下面的呢?添加子视图UIImagePickerController的cameraOverlayView上的cocos2d视图(openGLView)

[[[CCDirector sharedDirector] openGLView].superview addSubview:uip.view];
[[[[CCDirector sharedDirector] openGLView] removeFromSuperview];
uip.cameraOverlayView = [[CCDirector sharedDirector] openGLView];

另外,您还需要。

对不起,我想在UIImagePickerController顶部显示标签-将COCO移动到UIImagePickerController顶部感谢您的帮助,但它不会显示COCO元素-我有[CCDirector sharedDirector].openGLView.backgroundColor=[UIColor clearColor];[CCDirector sharedDirector].openGLView.opaque=NO;glBlendFunc(GL_ONE,GL_ONE减去SRC_ALPHA);glClearColor(0.0,0.0,0.0,0.0);glClear(GL_颜色_缓冲_位| GL_深度_缓冲_位);并添加了[[[CCDirector sharedDirector]openGLView].superview添加子视图:uip.view];[[CCDirector sharedDirector]openGLView]removeFromSuperview];[uip.cameraOverlayView添加子视图:[[CCDirector sharedDirector]openGLView];请尝试使用glClearColor(1.0、0.0、0.0、1.0),以确保在cameraOverlayView上显示EagleView。这应该会让屏幕变红。我误解了!“uip.cameraOverlayView=[[CCDirector sharedDirector]openGLView];”怎么样!?在调用openGLView的任何removeFromSuperview之前,请先获取superview,在CC_DIRECTOR_INIT()之后应该可以。对不起,我想要的是在UIImagePickerController顶部显示标签-在UIImagePickerController顶部移动COCO感谢您的帮助,但它没有显示COCO元素-我有[CCDirector sharedDirector].openGLView.backgroundColor=[UIColor clearColor];[CCDirector sharedDirector].openGLView.不透明=否;glBlendFunc(GL_ONE,GL_ONE _减去_SRC_ALPHA);glClearColor(0.0,0.0,0.0);glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER__BIT);并添加[[CCDirector sharedDirector]openGLView].superview addSubview:uip.view];[[CCDirector sharedDirector]openGLView]removeFromSuperview];[uip.CameraOverlyView addSubview:[CCDirector sharedDirector]openGLView];请尝试使用glClearColor(1.0,0.0,1.0)确保EagleView位于CameraOverlyView上。它会使屏幕变红。我误解了!怎么样“uip.cameraOverlayView=[[CCDirector sharedDirector]openGLView];”!?请在调用openGLView的任何removeFromSuperview之前获取superview,在CC_DIRECTOR_INIT()应该确定之后。