2

私はgamecentreについて何も知りません。私はgamecenterガイドを通過したCOCOアプリケーションに取り組んでおり、ゲームセンターをアプリケーションに統合できるようになっています。

1) これで、アプリケーションを介してゲームセンターにスコアを入力できるようになりました。 これを行うことによって:-

- (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で可能だと知りました

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
    }
}

しかし、理由はわかりませんが、GKMatchmakerViewControllerのデリゲートメソッドが呼び出されていません。デリゲートを設定しましたが、それでもGKMATCH(ここではcurrentMatch)を取得できません。したがって、このため[currentMatch sendDataToAllPlayers:data withDataMode:GKMatchSendDataUnreliable error:&error]; この方法は機能していません。

CurrentMatchの参照は0X0であるため。助けてください。データを送受信するにはどうすればよいですか。私は何か間違ったことをしていますか?または他にやるべきことがありますか?

私を助けてください。

ありがとう

4

0 に答える 0