我正在使用Game Center排行榜处理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];
}
答案 0 :(得分:1)
嗯,你的问题听起来有点讨厌,我能提供的只是猜测问题可能在哪里..
我有一个集成了排行榜的Cocos2d游戏,触摸效果非常好,所以让我给你详细介绍我如何添加排行榜viewController,你可能想尝试一下:
注意: 通常使用rootViewController在cocos2d中使用UIKit元素更好,在v0.99.5中添加。
//Action method invoked upon pressing the "Show LeaderBoards button"
-(void)showLeaderboardButtonClicked {
[gameCenterHandler showLeaderboard];
}
//Inside the GameCenter Handler:
-(void) showLeaderboard {
if (isGameCenterAvailable == NO) {
return;
} else if (![[GKLocalPlayer localPlayer] isAuthenticated]) {
[self authenticateLocalPlayer];
} else {
GKLeaderboardViewController* leaderboardVC = [[[GKLeaderboardViewController alloc] init] autorelease];
if (leaderboardVC != nil) {
leaderboardVC.leaderboardDelegate = self;
[rootVC presentModalViewController:leaderboardVC animated:YES];
}
}
-(void) leaderboardViewControllerDidFinish:(GKLeaderboardViewController*)viewController {
[rootVC dismissModalViewControllerAnimated:YES];
}
rootVC
位于AppDelegate.h
的位置:
RootViewController *viewController;