2012-05-03 153 views
2

我該如何讓CCTransitionPageTurn以鏡像方式將頁面捲曲到當前如何實現(就像您希望翻轉阿拉伯書的頁面一樣)。 這裏是CCActionPageTurn3D,我會在哪裏翻轉角度或使用(1024 - x)? :-)Cocos2D CCTransitionPageTurn從左至右

-(void)update:(ccTime)time 
{ 
    float tt = MAX(0, time - 0.25f); 
    float deltaAy = (tt * tt * 500); 
    float ay = -100 - deltaAy; 

    float deltaTheta = - (float) M_PI_2 * sqrtf(time) ; 
    float theta = /*0.01f*/ + (float) M_PI_2 +deltaTheta; 

    float sinTheta = sinf(theta); 
    float cosTheta = cosf(theta); 

    for(int i = 0; i <=gridSize_.x; i++) 
    { 
     for(int j = 0; j <= gridSize_.y; j++) 
     { 
      // Get original vertex 
      ccVertex3F p = [self originalVertex:ccg(i,j)]; 

      float R = sqrtf(p.x*p.x + (p.y - ay) * (p.y - ay)); 
      float r = R * sinTheta; 
      float alpha = asinf(p.x/R); 
      float beta = alpha/sinTheta; 
      float cosBeta = cosf(beta); 

      // If beta > PI then we've wrapped around the cone 
      // Reduce the radius to stop these points interfering with others 
      if(beta <= M_PI) 
       p.x = (r * sinf(beta)); 
      else 
      { 
       // Force X = 0 to stop wrapped 
       // points 
       p.x = 0; 
      } 

      p.y = (R + ay - (r*(1 - cosBeta)*sinTheta)); 

      // We scale z here to avoid the animation being 
      // too much bigger than the screen due to perspectve transform 
      p.z = (r * (1 - cosBeta) * cosTheta)/7; // "100" didn't work for 

      // Stop z coord from dropping beneath underlying page in a transition 
      // issue #751    
      if(p.z<0.5f) 
       p.z = 0.5f; 

      // Set new coords 
      [self setVertex:ccg(i,j) vertex:p]; 
     } 
    } 
} 
+0

兩者你找到了解決辦法? – Samidjo

回答

1

使用CCTransitionPageTurn並把向後屬性爲YES。

- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { 

    CGSize screenSize = [[CCDirector sharedDirector] winSize]; 

    UITouch *touch = [touches anyObject]; 
    CGPoint location = [touch locationInView:[touch view]]; 
    location = [[CCDirector sharedDirector] convertToGL:location]; 

    if (location.x < (screenSize.width * .25) && location.y < (screenSize.height * .25)) { 

    CCTransitionPageTurn *transition = [CCTransitionPageTurn transitionWithDuration:1.75 scene:[Page1 scene] backwards:YES]; 
    [[CCDirector sharedDirector] replaceScene:transition]; 
    } 

    if (location.x > (screenSize.width * .75) && location.y < (screenSize.height * .25)) { 

    CCTransitionPageTurn *transition = [CCTransitionPageTurn transitionWithDuration:1.75 scene:[Page3 scene] backwards:NO]; 
    [[CCDirector sharedDirector] replaceScene:transition]; 
    } 
    } 

here