Cocos2D 与 Cocos2D排行榜
我正在处理带有游戏中心排行榜的 Cocos2D iPhone 应用程序。在这个应用程序中,用户必须在横向模式下画线(iPhone 是水平的)。然后,触摸可能会从屏幕外部(靠近麦克风的左侧)开始,并在屏幕内部继续。一旦手指进入屏幕框架,应用程序就会正确开始绘制内容。但是,如果我用排行榜显示视图(实际上正确描述)并且我返回游戏,则应用程序将停止处理从屏幕外部开始的触摸。它实际上停止只处理那些从屏幕顶部开始的像素,就好像顶部有一行像素没有被考虑一样。
我以这种方式启动领导板:
- (void) showLeaderboard
{
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != nil){
tempVC=[[UIViewController alloc] init] ;
leaderboardController.leaderboardDelegate = self;
[[[CCDirector sharedDirector] openGLView] addSubview:tempVC.view];
[tempVC presentModalViewController:leaderboardController animated:YES];
tempVC.view.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0.0f));
tempVC.view.bounds = CGRectMake(0, 0, 480, 320);
tempVC.view.center = CGPointMake(240, 160);
[leaderboardController release];
}
}
并以这种方式发布:
-(void) leaderboardViewControllerDidFinish: (GKLeaderboardViewController *) viewController{
[tempVC dismissModalViewControllerAnimated:YES];
[tempVC.view.superview removeFromSuperview];
[tempVC.view removeFromSuperview];
[tempVC release];
}
I am dealing with a Cocos2D iPhone app with the Game Center Leaderboard. In this app the user has to draw lines in a landscape mode (the iPhone is horizontal). It happens then that the touch may begin outside the screen (in the left side near the microphone) and continue inside the screen. The app correctly starts drawing things as soon as the finger enters in the screen framework. However if I show the view with the leaderboard (that is actually correctly depicted) and I come back to the game the app stops handling touches that begin outside of the screen. It actually stops handling only those starting on the top of the screen as if there is a line of pixel at the top that are not considered.
I started the leaders board this way:
- (void) showLeaderboard
{
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != nil){
tempVC=[[UIViewController alloc] init] ;
leaderboardController.leaderboardDelegate = self;
[[[CCDirector sharedDirector] openGLView] addSubview:tempVC.view];
[tempVC presentModalViewController:leaderboardController animated:YES];
tempVC.view.transform = CGAffineTransformMakeRotation(CC_DEGREES_TO_RADIANS(0.0f));
tempVC.view.bounds = CGRectMake(0, 0, 480, 320);
tempVC.view.center = CGPointMake(240, 160);
[leaderboardController release];
}
}
and release it this way:
-(void) leaderboardViewControllerDidFinish: (GKLeaderboardViewController *) viewController{
[tempVC dismissModalViewControllerAnimated:YES];
[tempVC.view.superview removeFromSuperview];
[tempVC.view removeFromSuperview];
[tempVC release];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,你的问题听起来有点令人讨厌,我所能提供的只是猜测问题可能出在哪里。
我有一个集成了排行榜的 Cocos2d 游戏,并且触摸效果很好,所以让我向您详细介绍如何我添加了排行榜viewController,你可能想尝试一下:
注意:通常最好使用cocos2d中的UIKit元素使用RootViewController,添加在v0.99.5。
其中
rootVC
位于AppDelegate.h
中:Well, your problem sounds a bit nasty, and all I can provide is a guess to where the problem might be..
I have a Cocos2d Game with Leaderboards integrated, and the touches are working perfectly, so let me give you the details on how I add the leaderboard viewController, and you might want to try it out:
Note:It is generally better to use UIKit elements in cocos2d using the RootViewController, added in v0.99.5.
Where
rootVC
is inAppDelegate.h
: