2010-09-06 83 views
0

我嘗試在前奏完成時顯示介紹和替換場景。但是,當電影完成時,應用程序崩潰[[CCDirector sharedDirector] replaceScene:[CCFadeTransition transitionWithDuration:0.5f scene:[MenuScene scene]]] ;.cocos2d和MPMoviePlayerController崩潰

代碼是;

- (void) moviePlayBackDidFinish { 

[self.movi​​ePlayer 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.movi​​ePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];

//註冊以在電影完成播放時收到通知。
[[NSNotificationCenter defaultCenter]的addObserver:自
選擇器:@selector(moviePlayBackDidFinish :)
名:MPMoviePlayerPlaybackDidFinishNotification
對象:self.movi​​ePlayer];

如果([self.movi​​ePlayer respondsToSelector:@selector(setFullscreen:動畫:)]){
//使用新3.2風格的API
self.movi​​ePlayer.controlStyle = MPMovieControlStyleNone;
self.movi​​ePlayer.shouldAutoplay = YES;
//這會在cocos2d中爆炸,所以我們將手動調整大小
// [moviePlayer setFullscreen:YES animated:YES];
[self.movi​​ePlayer.view setTransform:CGAffineTransformMakeRotation((float)M_PI_2)];
CGSize winSize = [[CCDirector sharedDirector] winSize];
self.movi​​ePlayer.view.frame = CGRectMake(0,0,winSize.height,winSize.width); //寬度和高度在旋轉後交換
[[[CCDirector sharedDirector] openGLView] addSubview:self.movi​​ePlayer。視圖];
} else {
//使用舊的2.0風格API
self.movi​​ePlayer.movi​​eControlMode = MPMovieControlModeHidden;
[self。電影播放];
}

}

迴歸自我; }

回答

0

這條線: 選擇器:@selector(moviePlayBackDidFinish :)

應該是: 選擇器:@selector(moviePlayBackDidFinish)

0

CCScene *場景= [AboutLayer場景];

CCTransitionFade* transitionScene = [CCTransitionFade transitionWithDuration:0.1 scene:scene withColor:ccWHITE]; 
[[CCDirector sharedDirector] pushScene:transitionScene];