如何在播放电影时出现菜单-iphone cocos2d
我使用以下代码播放电影
NSString *path = [[NSBundle mainBundle] pathForResource:@"cobra" ofType:@"mp4"];
theMovie=[[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];
theMovie.scalingMode=MPMovieScalingModeAspectFill;
// Add an observer to catch when playback ends
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(transition:)
name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
// Start playback
theMovie.movieControlMode = MPMovieControlModeDefault;
[theMovie play];
现在我想在播放的电影上有一个菜单。我的代码如下
MenuItemImage *item1 = [MenuItemImage itemFromNormalImage:@"Button_cobra.png" selectedImage:@"Button_cobra1.png" target:self selector:@selector (transition:)];
Menu *menu = [Menu menuWithItems:item1, nil];
menu.position = CGPointZero;
item1.position = ccp(330,260);
item1.scale = 0.5;
[self addChild:menu z:51];
NSLog(@"Leaving Layer2");
但菜单没有显示。 谁能告诉我该怎么做。
I play a movie using the following code
NSString *path = [[NSBundle mainBundle] pathForResource:@"cobra" ofType:@"mp4"];
theMovie=[[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];
theMovie.scalingMode=MPMovieScalingModeAspectFill;
// Add an observer to catch when playback ends
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(transition:)
name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
// Start playback
theMovie.movieControlMode = MPMovieControlModeDefault;
[theMovie play];
now i want to have a menu over the playing movie.I code like
MenuItemImage *item1 = [MenuItemImage itemFromNormalImage:@"Button_cobra.png" selectedImage:@"Button_cobra1.png" target:self selector:@selector (transition:)];
Menu *menu = [Menu menuWithItems:item1, nil];
menu.position = CGPointZero;
item1.position = ccp(330,260);
item1.scale = 0.5;
[self addChild:menu z:51];
NSLog(@"Leaving Layer2");
But the menu is not getting displayed.
Can anyone please tell me how to do it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须等到窗口加载完毕,然后执行类似的操作。
PlayerOverlayView 没什么特别的。只是我制作的 UIView 子类。我从
回调中调用它,效果很好。
You have to wait until the window is loaded and then do something like this.
PlayerOverlayView is nothing special. Just a UIView subclass i made. I call this from the
callback and it works great.