我嘗試在前奏完成時顯示介紹和替換場景。但是,當電影完成時,應用程序崩潰[[CCDirector sharedDirector] replaceScene:[CCFadeTransition transitionWithDuration:0.5f scene:[MenuScene scene]]] ;.cocos2d和MPMoviePlayerController崩潰
代碼是;
- (void) moviePlayBackDidFinish {
[self.moviePlayer stop]; [CCDirector sharedDirector] replaceScene:[CCFadeTransition transitionWithDuration:0.5f scene:[MenuScene scene]]];;} [ }
- (ID)初始 {
//隨時撥打 「超級」 初始化 //蘋果建議重新分配的 「自我」 與 「超級」 的返回值 IF((自我= [超級INIT])){// pencere boyutu埃爾德河ediliyor
NSURL * URL = [NSURL fileURLWithPath:[[一個NSBundle mainBundle] pathForResource:@ 「前奏」 ofType:@ 「MP4」]]; self.moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
//註冊以在電影完成播放時收到通知。
[[NSNotificationCenter defaultCenter]的addObserver:自
選擇器:@selector(moviePlayBackDidFinish :)
名:MPMoviePlayerPlaybackDidFinishNotification
對象:self.moviePlayer];
如果([self.moviePlayer respondsToSelector:@selector(setFullscreen:動畫:)]){
//使用新3.2風格的API
self.moviePlayer.controlStyle = MPMovieControlStyleNone;
self.moviePlayer.shouldAutoplay = YES;
//這會在cocos2d中爆炸,所以我們將手動調整大小
// [moviePlayer setFullscreen:YES animated:YES];
[self.moviePlayer.view setTransform:CGAffineTransformMakeRotation((float)M_PI_2)];
CGSize winSize = [[CCDirector sharedDirector] winSize];
self.moviePlayer.view.frame = CGRectMake(0,0,winSize.height,winSize.width); //寬度和高度在旋轉後交換
[[[CCDirector sharedDirector] openGLView] addSubview:self.moviePlayer。視圖];
} else {
//使用舊的2.0風格API
self.moviePlayer.movieControlMode = MPMovieControlModeHidden;
[self。電影播放];
}
}
迴歸自我; }