我有兩個CCScenes
,我們稱他們爲A和B.當我在場景中我用視頻播放器呈現一個UIViewController
實例。然後我想從UIViewController的現場B.移動這就是我如何做到這一點:如何在UIViewController提供時替換CCScene?
- (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
獲取到場景B RIGHT。但不幸的是,它總是把我帶到場景A一會兒,然後纔出現場景B.據我瞭解,顯示UIViewController
區塊Cocos2D
,以便它只能在從CCDirector
中刪除viewController後才起作用。所以我需要找到一種方法來異步替換CCScene
而viewController仍然在。有任何想法嗎?