我有两个CCScenes
,我们称它们为 A 和 B。当我在现场 A 时,我会展示一个UIViewController
带有视频播放器的实例。然后我想从那个 UIViewController 移动到场景 B。这就是我这样做的方式:
- (void)videoFinished:(NSNotification *)notification
{
[self presentCurrentActivity];
id object = notification.object;
if ([notification.name isEqualToString:AVPlayerItemDidPlayToEndTimeNotification])
[RAActivityInfoManager setVideoWatched];
[[NSNotificationCenter defaultCenter] removeObserver:self name:AVPlayerItemDidPlayToEndTimeNotification object:object];
[[NSNotificationCenter defaultCenter] removeObserver:self name:VIDEO_SKIPPED_NOTIFICATION object:nil];
[[CCDirector sharedDirector] dismissViewControllerAnimated:YES completion:nil];
}
- (void)presentCurrentActivity
{
if (currentActivity >= numberOfActivitiesInLesson)
currentActivity = 1;
NSString *className = self.activityNames[currentActivity];
Class class = NSClassFromString(className);
[RAActivityInfoManager addSpriteFramesForClass:class];
SEL selector = sel_registerName("scene");
CCScene *scene = [class performSelector:selector];
[[CCDirector sharedDirector] replaceScene:scene];
}
我所需要的只是在解雇我的UIViewController
. 但不幸的是,它总是把我带到场景 A 片刻,然后才呈现场景 B。据我了解显示UIViewController
块Cocos2D
,以便它只能在 viewController 从CCDirector
. 所以我需要找到一种CCScene
在 viewController 仍然打开时异步替换的方法。有任何想法吗?