popScene也带效果

阅读更多

原地址:http://ityran.com/thread-118-1-1.html

 

写一个CCDirector(Extension)这样的Category

在头文件中加入:
@interface CCDirector(Extension)
/**Pops scene with transitions
*/
- (void) popSceneWithTransition: (Class)c duration:(ccTime)t;

@end

在实现文件中加入:
-(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;
        }
}

你可能感兴趣的:(CCDirector)