Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX CCDirector's popToRootSceneWithTransition (running scene onExitTransitionDidStart and onExit where called twice) #1356

Open
wants to merge 1 commit into
base: v3.4.9
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions cocos2d/CCDirector.m
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,14 @@ -(void) popToRootScene
}

-(void) popToRootSceneWithTransition:(CCTransition *)transition {
[self popToRootScene];
_sendCleanupToScene = YES;
[transition startTransition:_nextScene];
[self popToSceneStackLevel:1 withTransition:transition];
}

-(void) popToSceneStackLevel:(NSUInteger)level
-(void) popToSceneStackLevel:(NSUInteger)level {
return [self popToSceneStackLevel:level withTransition:nil];
}

-(void) popToSceneStackLevel:(NSUInteger)level withTransition:(CCTransition *)transition
{
NSAssert(_runningScene != nil, @"A running Scene is needed");
NSUInteger c = [_scenesStack count];
Expand All @@ -617,7 +619,7 @@ -(void) popToSceneStackLevel:(NSUInteger)level
// pop stack until reaching desired level
while (c > level) {
CCScene *current = [_scenesStack lastObject];
if( current.runningInActiveScene ){
if( current.runningInActiveScene && transition == nil ){
[current onExitTransitionDidStart];
[current onExit];
}
Expand All @@ -627,7 +629,10 @@ -(void) popToSceneStackLevel:(NSUInteger)level
c--;
}
_nextScene = [_scenesStack lastObject];
_sendCleanupToScene = NO;
_sendCleanupToScene = transition != nil;
if (transition) {
[transition startTransition:_nextScene];
}
}

// -----------------------------------------------------------------
Expand Down