当我在cocos2d中调用relpaceScene或pushScene时,可以向其添加一些过渡,例如:
[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:1 scene:scene]];
但是当我调用popScene时,它不带任何参数,也不能添加任何过渡。是这样吗?
我该如何在PopScene中进行所需的转换?
最佳答案
在cocos2d论坛中的Per Guy似乎可行:Link to Forum
在声明-(void)popScene(第402行)之后,将其添加到CCDirector.h中:
- (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;
}
}
您可以这样调用方法:
[[CCDirector sharedDirector] popSceneWithTransition:[CCSlideInRTransition class] durat
关于cocos2d-iphone - 如何在cocos2d中使用popScene进行过渡?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7021519/