I try to show an intro and replaceScene when the intro has finished开发者_开发知识库. But, when the movie finish, app is crashing on [[CCDirector sharedDirector] replaceScene:[CCFadeTransition transitionWithDuration:0.5f scene:[MenuScene scene]]];.
code is;
- (void) moviePlayBackDidFinish {
[self.moviePlayer stop];
[[CCDirector sharedDirector] replaceScene:[CCFadeTransition transitionWithDuration:0.5f scene:[MenuScene scene]]]; }
-(id) init {
// always call "super" init // Apple recommends to re-assign "self" with the "super" return value if( (self=[super init] )) { //pencere boyutu elde ediliyor
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"intro" ofType:@"mp4"]]; self.moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
// Register to receive a notification when the movie has finished playing.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.moviePlayer];if ([self.moviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {
// Use the new 3.2 style API self.moviePlayer.controlStyle = MPMovieControlStyleNone; self.moviePlayer.shouldAutoplay = YES; // This does blows up in cocos2d, so we'll resize manually // [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);// width and height are swapped after rotation [[[CCDirector sharedDirector] openGLView] addSubview:self.moviePlayer.view]; } else { // Use the old 2.0 style API self.moviePlayer.movieControlMode = MPMovieControlModeHidden; [self.moviePlayer play]; }}
return self; }
This line: selector:@selector(moviePlayBackDidFinish:)
should be: selector:@selector(moviePlayBackDidFinish)
CCScene* scene = [AboutLayer scene];
CCTransitionFade* transitionScene = [CCTransitionFade transitionWithDuration:0.1 scene:scene withColor:ccWHITE];
[[CCDirector sharedDirector] pushScene:transitionScene];
精彩评论