Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 有关gamecenter+;网间网操作系统_Iphone_Ios_Game Center - Fatal编程技术网

Iphone 有关gamecenter+;网间网操作系统

Iphone 有关gamecenter+;网间网操作系统,iphone,ios,game-center,Iphone,Ios,Game Center,我对gamecentre一无所知。我正在开发COCO应用程序 我已经通过并能够将游戏中心集成到我的应用程序中 (一) 现在,我可以通过我的应用程序在游戏中心输入分数。 通过这样做:- - (void) reportScore: (int64_t) score forCategory: (NSString*) category { GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:category] autorelea

我对gamecentre一无所知。我正在开发COCO应用程序 我已经通过并能够将游戏中心集成到我的应用程序中

(一) 现在,我可以通过我的应用程序在游戏中心输入分数。 通过这样做:-

- (void) reportScore: (int64_t) score forCategory: (NSString*) category 
{
    GKScore *scoreReporter = [[[GKScore alloc] initWithCategory:category] autorelease]; 
    scoreReporter.value = score;
    [scoreReporter reportScoreWithCompletionHandler: ^(NSError *error) 
     {
         [self callDelegateOnMainThread: @selector(scoreReported:) withArg: NULL error: error];
     }];
}
我昨天正常工作。但是现在如果我尝试更新分数,它不会更新。请任何人知道游戏中心分数不更新的原因 我曾试图寻找,但什么也没有得到

2)我想将一个玩家的当前纬度和经度发送给另一个玩家。 我知道通过GKMATCH是可能的

但是我不知道为什么GKMatchmakerViewController的委托方法没有被调用。我已经设置了委托,但是我仍然不能得到GKMATCH(这里是currentMatch)。 那么由于这个, [currentMatch sendDataToAllPlayers:data with DataMode:GKMatch SendDataUnreliable error:&error]; 这种方法不起作用

因为CurrentMatch引用是0X0。 请帮助我。我如何发送和接收数据。 我做错什么了吗?或者还有什么事情要做吗

请帮帮我

谢谢

GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
    request.minPlayers = 1;
    request.maxPlayers = 1;

    [[GKMatchmaker sharedMatchmaker] findMatchForRequest:request
                                   withCompletionHandler:^(GKMatch *match, NSError *error) {
                                       if (error || !match) {
                                           // handle the error
                                       }
                                       else if (match != nil){
                                           // match found
                                       }}];

    /*GKMatchRequest *request = [[[GKMatchRequest alloc] init] autorelease];
    request.minPlayers = 1;
    request.maxPlayers = 1;
    GKMatchmakerViewController *mmvc = [[GKMatchmakerViewController alloc] initWithMatchRequest:request];
    mmvc.matchmakerDelegate = self;
    currentMatch.delegate=self;
    [self presentModalViewController:mmvc animated:YES];*/
    //[mmvc release];
}
- (void)match:(GKMatch *)match player:(NSString *)playerID didChangeState:(GKPlayerConnectionState)state {
    switch (state){
        case GKPlayerStateConnected: 
            if (match.expectedPlayerCount == 0) {
                // start the match
            }
            break;
        case GKPlayerStateDisconnected:
            // remove the player from the match, notify other players, etc
            break;
    } 
}
- (void)matchmakerViewControllerWasCancelled:(GKMatchmakerViewController *)viewController{}

// Matchmaking has failed with an error
- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFailWithError:(NSError *)error{
}


// A peer-to-peer match has been found, the game should start
- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match{
}

// Players have been found for a server-hosted game, the game should start
- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindPlayers:(NSArray *)playerIDs{
}

// An invited player has accepted a hosted invite.  Apps should connect through the hosting server and then update the player's connected state (using setConnected:forHostedPlayer:)
- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didReceiveAcceptFromHostedPlayer:(NSString *)playerID {
}
- (void) sendPosition
{
    NSError *error;
    NSString* str = @"teststring";
    NSData* data = [str dataUsingEncoding:NSUTF8StringEncoding];
    //  NSData *packet = [NSData dataWithBytes:&msg length:sizeof(PositionPacket)];
    [currentMatch sendDataToAllPlayers: data withDataMode: GKMatchSendDataUnreliable error:&error];
    if (error != nil)
    {
        // Handle the erro.r
    }
}