开发者

Cocos2d Custom Scene Transition -- Book Cover Opening

I am trying to create a custom scene transition in Cocos2D for iOS that will simulate the opening of a book cover.

The out-going scene must flip open to the left (hinged on the left edge of the screen) and display the in-coming scene as if it where the first page of the book just being uncovered by the out-going scene.

Any ideas on how to do this?

I was able to create a subclass of CCTransitionSceneOriented the performs a simple, book cover transition, unfortunately is not professional looking because the in-coming scene is not incrementally displayed as the cover is opened :-(

@implementation TransitionBookCover

-(void) onEnter
{
    [super onEnter];
    开发者_JS百科[inScene_ setVisible:NO];

    id  outCameraAct = [CCOrbitCamera actionWithDuration:duration_/2 radius:1 deltaRadius:0 angleZ:180 deltaAngleZ:65 angleX:0 deltaAngleX:0];
    id outHideAct   = [CCHide action];
    id outDelayAct  = [CCDelayTime actionWithDuration:duration_/2];
    id outGroupAct1 = [CCSequence actions:outCameraAct, outHideAct, outDelayAct, nil];
    id outMoveAct   = [CCMoveTo actionWithDuration:duration_/4 position:ccp(-384.0,0.0)];
    id outGroupAct2 = [CCSpawn actions:outMoveAct, outGroupAct1, nil];

    id inDelayAct = [CCDelayTime actionWithDuration:duration_/2];
    id inShowAct  = [CCShow action];
    id inFuncAct  = [CCCallFunc actionWithTarget:self selector:@selector(finish)];
    id inGroupAct = [CCSequence actions:inDelayAct, inShowAct, inFuncAct, nil];

    [outScene_ runAction:outGroupAct2];
    [inScene_ runAction:inGroupAct];    
}

@end.


You may not have to do this with scenes. You can do it cheaply 2 ways:

  1. pre-render the book cover opening and run it as an animation
  2. make the cover a sprite on the "first page" and then just shrink the x coordinate until it disappears. I'm not sure how to get a "trapezoidal" effect in Cocos2D.

CCTransitionFlipX is more for flipping a card over, than the 1st page of a book.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜