2013-08-23 40 views
1

我想從主攝像頭視圖向前放置一個UIView在Z軸上。我添加了如下所示的代碼。我正在嘗試使用CATransform3DTranslate,但JAPanoView(其視圖)不會顯示在提到的Z軸值轉發到相機視圖。有人可以請指教,我該如何實現它?Z軸支持查看UIView

-(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]; 
} 
+0

試試用一個普通的UIButton。一般來說,可能無法在UIView上執行3D轉換。或者在添加視圖後嘗試應用轉換。這是我想嘗試的兩件事。 – LearnCocos2D

+0

我在視圖中添加後嘗試轉換,但它不能解決問題。 – Getsy

+0

我的示例項目是在這裏 - > https://www.hightail.com/download/bWJyYUluT2IzS3FLRmNUQw – Getsy

回答

1

UIViews的z順序是它們在其超級視圖的子視圖屬性中的順序。要在子視圖之前在另一個用戶可以用戶,你可以簡單addSubview他們在正確的順序,把他們在XIB文件中的順序或使用bringSubviewToFront。