Skip to content

Instantly share code, notes, and snippets.

@dunvi
Created April 10, 2013 22:54
Show Gist options
  • Save dunvi/5359174 to your computer and use it in GitHub Desktop.
Save dunvi/5359174 to your computer and use it in GitHub Desktop.
from the commit message: Added a popSceneWithTransition function. Its use is as follows: [[CCDirector sharedDirector] popSceneWithTransition:[<transition type here> class] duration:<float value here>]; code snippets from <www.cocos2d-iphone.org/forum/topic/1076>.
- (void) popSceneWithTransition: (Class)c duration:(ccTime)t;
- (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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment