- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我按照本教程 http://www.raywenderlich.com/3276/how-to-make-a-simple-multiplayer-game-with-game-center-tutorial-part-12但是配对窗口并没有打开。 DropBox 源码链接https://www.dropbox.com/s/e4pp95iqqo6xkrw/testCocos2d%202.zip
- (void)findMatchWithMinPlayers:(int)minPlayers maxPlayers:(int)maxPlayers viewController:(UIViewController *)viewController delegate:(id<GCHelperDelegate>)theDelegate {
if (!gameCenterAvailable) return;
matchStarted = NO;
self.match = nil;
self.presentingViewController = viewController;
delegate = theDelegate;
if (pendingInvite != nil) {
[presentingViewController dismissModalViewControllerAnimated:NO];
GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithInvite:pendingInvite] autorelease];
mmvc.matchmakerDelegate = self;
[presentingViewController presentModalViewController:mmvc animated:YES];
self.pendingInvite = nil;
self.pendingPlayersToInvite = nil;
} else {
GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
request.minPlayers = minPlayers;
request.maxPlayers = maxPlayers;
request.playersToInvite = pendingPlayersToInvite;
GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
mmvc.matchmakerDelegate = self;
[presentingViewController presentViewController:mmvc animated:YES completion:nil];
self.pendingInvite = nil;
self.pendingPlayersToInvite = nil;
}
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Init the window
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
CCDirector *director = [CCDirector sharedDirector];
EAGLView *glView = [EAGLView viewWithFrame:[self.window bounds]
pixelFormat:kEAGLColorFormatRGB565 // kEAGLColorFormatRGBA8
depthFormat:0 // GL_DEPTH_COMPONENT16_OES
];
// attach the openglView to the director
[director setOpenGLView:glView];
// // Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
if( ! [director enableRetinaDisplay:YES] )
CCLOG(@"Retina Display Not supported");
[director setAnimationInterval:1.0/60];
// make the OpenGLView a child of the view controller
[viewController setView:glView];
// make the View Controller a child of the main window
self.window.rootViewController = viewController;
if( ! [director enableRetinaDisplay:YES] )
CCLOG(@"Retina Display Not supported");
// Create a Navigation Controller with the Director
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:director];
navController.navigationBarHidden = YES;
NSString *reqSysVer = @"6.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
{
[self.window setRootViewController:navController];
} else
{
[self.window addSubview: navController.view];
}
[self.window makeKeyAndVisible];
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
// Removes the startup flicker
[self removeStartupFlicker];
[[GCHelper sharedInstance] authenticateLocalUser];
// Run the intro Scene
[[CCDirector sharedDirector] runWithScene: [HelloWorldLayer scene]];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Init the window
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
CCDirector *director = [CCDirector sharedDirector];
EAGLView *glView = [EAGLView viewWithFrame:[self.window bounds]
pixelFormat:kEAGLColorFormatRGB565 // kEAGLColorFormatRGBA8
depthFormat:0 // GL_DEPTH_COMPONENT16_OES
];
// attach the openglView to the director
[director setOpenGLView:glView];
// // Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
if( ! [director enableRetinaDisplay:YES] )
CCLOG(@"Retina Display Not supported");
[director setAnimationInterval:1.0/60];
// make the OpenGLView a child of the view controller
[viewController setView:glView];
// make the View Controller a child of the main window
self.window.rootViewController = viewController;
if( ! [director enableRetinaDisplay:YES] )
CCLOG(@"Retina Display Not supported");
// Create a Navigation Controller with the Director
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:director];
navController.navigationBarHidden = YES;
NSString *reqSysVer = @"6.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
{
[self.window setRootViewController:navController];
} else
{
[self.window addSubview: navController.view];
}
[self.window makeKeyAndVisible];
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
// Removes the startup flicker
[self removeStartupFlicker];
[[GCHelper sharedInstance] authenticateLocalUser];
// Run the intro Scene
[[CCDirector sharedDirector] runWithScene: [HelloWorldLayer scene]];
}
- (void)authenticateLocalUser {
if (!gameCenterAvailable) return;
NSLog(@"Authenticating local user...");
if ([GKLocalPlayer localPlayer].authenticated == NO) {
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:nil];
} else {
NSLog(@"Already authenticated!");
}
}
最佳答案
好吧,几个月前我遇到了同样的问题,我解决这个问题的方法是将 mmvc 呈现为模态视图 Controller 。请尝试用以下内容替换您的 else:
[presentingViewController dismissModalViewControllerAnimated:NO];
GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
request.minPlayers = minPlayers;
request.maxPlayers = maxPlayers;
request.playersToInvite = pendingPlayersToInvite;
GKMatchmakerViewController *mmvc = [[[GKMatchmakerViewController alloc] initWithMatchRequest:request] autorelease];
mmvc.matchmakerDelegate = self;
[presentingViewController presentModalViewController:mmvc animated:YES];
self.pendingInvite = nil;
self.pendingPlayersToInvite = nil;
- (void)authenticateLocalUser {
if (!gameCenterAvailable) return;
NSLog(@"Authenticating local user...");
if ([GKLocalPlayer localPlayer].authenticated == NO) {
// Use new authentication mechanism if the iOS version is 6.0 or above
if ([[UIDevice currentDevice].systemVersion compare:@"6.0" options:NSNumericSearch] != NSOrderedAscending) {
[[GKLocalPlayer localPlayer] setAuthenticateHandler:^(UIViewController *vc, NSError *error) {
if (error)
NSLog(@"Error in authenticating User - %@", [error localizedDescription]);
else if (vc) {
AppDelegate *appDel = (AppDelegate *)[UIApplication sharedApplication].delegate;
[appDel.navigationController presentModalViewController:vc animated:YES];
}
}];
}
else
[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:nil];
}
else {
NSLog(@"Already authenticated!");
}
}
关于ios - GKMatchmakerViewController 未在 iOS 7 中打开,但在 iOS 5.1 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19445372/
我想创建一个自定义 GKMatchMakerViewController 符合标准 ViewController 的代码(彩色气泡): if([GKLocalPlayer localPlayer].
我正在为我制作的游戏制作多人游戏功能。 一切正常,除了当我正在配对并且两个玩家都已连接时,如果一个人点击“取消”按钮,另一台设备不会收到取消通知。 在另一台设备上,文字变为“已断开连接”,但是没有调用
我正在尝试制作一款使用实时比赛的简单在线多人游戏。但是,当我尝试启动 GKMatchmakerViewController 时,它会抛出一个错误。 这是我正在运行的当前代码: func openMat
由于某些原因,我们不想使用 GKMatchmakerViewController。目前,我们为应用程序的用户提供了通过 UI 中显示的好友列表邀请他们的 Game Center 好友的可能性。 虽然这
有没有办法检测何时按下 GKMatchmakerViewController 中的“立即播放”按钮? 我在引用文档中可以找到的所有内容是: – matchmakerViewController:did
我在尝试在游戏 View 上显示 GKMatchmakerViewController 时遇到问题。 通常情况下,我会通过自动匹配 2 个对手来以编程方式创建多人比赛,效果很好。 但是当我尝试显示标准
我正在将实时游戏中心应用到我的游戏中,但在呈现 GKMatchmakerViewController 时遇到问题.这是我的情况: 我在其中展示了 HomeViewController GameView
我花了几个小时尝试调试这个,所以我想我应该在这里发帖,也许可以帮助一些人解决这个问题! GKMatchRequest *matchRequest = [[GKMatchRequest alloc] i
我无法使用自动匹配和 GKMatchmakerViewController 在两个玩家之间建立连接。 行为是这样的: didFindMatch 被称为 expectedPlayerCount 不为零(
我正在使用游戏中心实现基于回合的多人游戏。第一个 View Controller (ViewController) 显示菜单并且已经可以显示 GKTurnBasedMatchmakerViewCont
我按照本教程 http://www.raywenderlich.com/3276/how-to-make-a-simple-multiplayer-game-with-game-center-tuto
我是一名优秀的程序员,十分优秀!