我正在使用MPMoviePlayerController
在CCMenu
. 所以我在一些按钮后面播放了一段视频。当我切换视图/场景时,我希望moviePlayer
让场景与该层/场景上的按钮/图像相同。
后台播放电影的代码如下:
-(void)playMainMenuVideo{
NSString *path=[[NSBundle mainBundle] pathForResource:@"MYMMainMenu" ofType:@"mov"];
MPMoviePlayerViewController * player=[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];
player.moviePlayer.controlStyle = MPMovieControlStyleNone;
[[player view] setFrame:[[[CCDirector sharedDirector]view] bounds]];
player.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
[[[CCDirector sharedDirector]view] addSubview:[player view]];
[[[CCDirector sharedDirector]view] sendSubviewToBack:player.view];
UIView* glView = [CCDirector sharedDirector].view; // attention
[glView.superview insertSubview:player.view atIndex:0]; // attention
glView.opaque = NO; // attention
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // attention
}
这很完美,在应用程序委托中我也改变了
CCGLView *glView = [CCGLView viewWithFrame:[window_ bounds]
pixelFormat:kEAGLColorFormatRGB565 // To kEAGLColorFormatRGBA8
最后我想做一个这样的翻页:
[[CCDirector sharedDirector] replaceScene: [CCTransitionPageTurn transitionWithDuration:1.0 scene:[FirstPageViewController scene]]];
但只有精灵会离开场景,视频会在后台播放。我怎样才能解决这个问题?提前致谢