Suggestion: PopScene with trasition

This topic has been talked in cocos2d but I don’t know if it is progressed. I think it can be done if CCDirector can provide an interface to apply trasitions to the pushed scene in stack.

I think the following link will be useful here :slight_smile:
http://code.google.com/p/cocos2d-iphone/issues/detail?id=334

But yeah, +1 for the feature.

#514 is just created. The feature must be cool.

Great!

Strawberry Milkshake, thank you for the link!

This was worked on in the Obj-C version of Cocos2d, and as far as I know, has not yet been added to the main branch. Porting this from Obj-C is pretty straightforward I would think, so here ya go

- (void) popSceneWithTransition: (Class)c duration:(ccTime)t;

Then add this to CCDirector.m, just after the definition of -(void)popScene (line 768):

-(void) popSceneWithTransition: (Class)transitionClass duration:(ccTime)t;
{
    NSAssert( runningScene_ != nil, @"A running Scene is needed");

    [scenesStack_ removeLastObject];
    NSUInteger c = [scenesStack_ count];
    if( c == 0 ) {
        [self end];
    } else {
        CCScene* scene = [transitionClass transitionWithDuration:t scene:[scenesStack_ objectAtIndex:c-1]];
        [scenesStack_ replaceObjectAtIndex:c-1 withObject:scene];
        nextScene_ = scene;
    }
}

edit: Whoops, jumped the gun there and didn’t see that the OP had posted back :stuck_out_tongue: Oh well

Is this feature already implemented in cocos2d-iphone gles20 branch?

As far as I know, it is not. The community has solved the issue, but I don’t think that Riq or the other contributors have got around to adding it quite yet