1

我想在 Z 轴上从主相机视图向前放置一个 UIView。我添加了如下代码。我正在尝试使用 CATransform3DTranslate,但 JAPanoView(它是一个 uiview)不会显示在提到的 Z 轴值中,该值位于相机视图的前方。有人可以建议,我该如何实现?

    -(void) initializeScene {

    // Create the camera, place it back a bit, and add it to the scene
    CC3Camera* cam = [CC3Camera nodeWithName: @"Camera"];
    cam.location = cc3v( 0.0, 0.0, 12.0 );
    [self addChild: cam];

    // Create a light, place it back and to the left at a specific
    // position (not just directional lighting), and add it to the scene
    CC3Light* lamp = [CC3Light nodeWithName: @"Lamp"];
    lamp.location = cc3v( 0.0, 40.0, 0.0 );
    lamp.isDirectionalOnly = NO;
    [cam addChild: lamp];

    // JAPanoView IS AN UIVIEW
    JAPanoView *panoView=[[JAPanoView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
    //self.view=panoView;
    panoView.delegate=self;
    [panoView setFrontImage:[UIImage imageNamed:@"Home_front.png"] rightImage:[UIImage imageNamed:@"Home_right.png"] backImage:[UIImage imageNamed:@"Home_back.png"] leftImage:[UIImage imageNamed:@"Home_left.png"] topImage:[UIImage imageNamed:@"Home_up.png"] bottomImage:[UIImage imageNamed:@"Home_down.png"]];

    CATransform3D _3Dt = CATransform3DIdentity;
    _3Dt = CATransform3DTranslate(_3Dt, 0, 0, -30);
    panoView.layer.transform = _3Dt;

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

    // Create OpenGL ES buffers for the vertex arrays to keep things fast and efficient,
    // and to save memory, release the vertex data in main memory because it is now redundant.
    [self createGLBuffers];
    [self releaseRedundantData];
}
4

1 回答 1

1

UIViews 的 z-order 是它们在其父视图的 subviews 属性中的顺序。要在另一个用户面前拥有子视图,您可以按正确的顺序简单地添加子视图,按此顺序将它们放在 XIB 文件中或使用bringSubviewToFront。

于 2013-08-31T17:54:58.910 回答