标签: gamekit

iOS Game Center提交float而不是int64_t

我试图向float我的游戏中心排行榜提交两位小数长度,但是唯一允许提交的格式是int64_t.我使用默认的Apple报告分数方法:

- (void)reportScore:(int64_t)score forCategory:(NSString *)category {
    GKScore *scoreReporter = [[GKScore alloc] initWithCategory:category];   
    scoreReporter.value = score;
    [scoreReporter reportScoreWithCompletionHandler: ^(NSError *error) {
        [self callDelegateOnMainThread: @selector(scoreReported:) withArg: NULL error: error];
    }];
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用此方法为报表分数方法提供分数:

- (IBAction)increaseScore {
    self.currentScore = self.currentScore + 1;
    currentScoreLabel.text = [NSString stringWithFormat: @"%lld", self.currentScore];
    NSLog(@"%lld", self.currentScore);
}
Run Code Online (Sandbox Code Playgroud)

请帮忙,我一直在谷歌上搜索疯狂,无法找到答案.

objective-c gamekit ios game-center gkscore

1
推荐指数
1
解决办法
3546
查看次数

GameKit排行榜GKScore initWithCategory - 为"类别"指定什么

我正在尝试为我的游戏设置排行榜,但我不知道要传递给GKScore:initWithCategory.在Itunes Connect中查看"排行榜参考名称"和"排行榜ID"这两个我已经尝试过,但现在游戏中心仍会显示分数.

在ITC中没有提到"类别",术语是否已更改?我将什么传递给这个功能?

iphone objective-c gamekit

1
推荐指数
1
解决办法
1490
查看次数

将游戏中心的朋友和他们的分数加载到UITableView中

所以我在阅读苹果文档后感到疑惑(https://developer.apple.com/library/ios/documentation/GameKit/Reference/GKLeaderboard_Ref/Reference/Reference.html#//apple_ref/occ/instp/GKLeaderboard/category)如何创建一个UITableView并用localPlayers Game Center朋友填充它,并在特定的排行榜中得分.我知道如何使用loadScoresWithCompletionHandler:方法单独获取好友列表和好友分数.

编辑:到目前为止,我得到了这个以获得个人朋友的照片,得分和显示名称保存到一个NSArray.但我无法弄清楚如何在UITableView中显示它们.

- (void) loadPlayerData: (NSArray *) identifiers
{
    GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] init];
    if (leaderboardRequest != nil) {
        leaderboardRequest.playerScope = GKLeaderboardPlayerScopeFriendsOnly;
        leaderboardRequest.timeScope = GKLeaderboardTimeScopeAllTime;
        leaderboardRequest.category = @"MJ_IL";
        [leaderboardRequest loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {
            if (error != nil) {
                    // handle the error. if (scores != nil)
           }

        if (scores != nil){
        for (GKScore* score in scores) {

            NSArray *playerIdArray = [NSArray arrayWithObject:score.playerID];
            [GKPlayer loadPlayersForIdentifiers:playerIdArray withCompletionHandler:^(NSArray *players, NSError *error) {

                GKPlayer *player = [players …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview gamekit ios game-center

1
推荐指数
1
解决办法
2560
查看次数

SwiftUI GKLeaderboard loadEntries

我想将排行榜添加到我的 SwiftUI 应用程序中。
我找不到任何使用 loadEntries 加载排行榜值的示例。我尝试了以下...

let leaderBoard: GKLeaderboard = GKLeaderboard()
leaderBoard.identifier = "YOUR_LEADERBOARD_ID_HERE"
leaderBoard.timeScope = .allTime
leaderBoard.loadScores { (scores, error) in ...
Run Code Online (Sandbox Code Playgroud)

这会导致以下警告:

  • “标识符”在 iOS 14.0 中已弃用:改为使用 loadEntriesForPlayerScope:timeScope:range:completionHandler:。
  • 'timeScope' 在 iOS 14.0 中被弃用:使用 loadEntriesForPlayerScope:timeScope:range:completionHandler: 代替。
  • 'loadScores(completionHandler:)' 在 iOS 14.0 中被弃用:使用 loadEntriesForPlayerScope:timeScope:range:completionHandler:。

使用 loadEntriesForPlayerScope 会导致以下警告:

  • “loadEntriesForPlayerScope(_:timeScope:range:completionHandler:)”已重命名为“loadEntries(for:timeScope:range:completionHandler:)”

使用loadEntries我不知道如何指定排行榜标识符。

gamekit game-center-leaderboard swiftui

1
推荐指数
1
解决办法
355
查看次数

分数提交失败

我在cocos2d中总是收到失败,但是当我在基于视图的应用程序中运行此项目时,它会给我成功,并且分数将很容易提交

[[GKLocalPlayer localPlayer] authenticateWithCompletionHandler:^(NSError *error){
    if (error ==nil) {
        NSLog(@"Success");
    } else {
        NSLog(@"Fail");
    }   
}];


GKScore *myScoreValue = [[[GKScore alloc] initWithCategory:@"123"] autorelease];
myScoreValue.value =  lastScore;

[myScoreValue reportScoreWithCompletionHandler:^(NSError *error){
    if(error != nil){
        NSLog(@"Score Submission Failed");
    } else {
        NSLog(@"Score Submitted");
    }

}];
Run Code Online (Sandbox Code Playgroud)

iphone objective-c gamekit

0
推荐指数
1
解决办法
1799
查看次数

GameKitHelper:显示游戏中心排行榜

我在我的Cocos2d游戏中使用GameKitHelper.在某些时候,我会想要显示排行榜,所以我这样做:

[[GameKitHelper sharedGameKitHelper] showLeaderboard];
Run Code Online (Sandbox Code Playgroud)

但没有任何反应.我该怎么办?

cocos2d-iphone gamekit

0
推荐指数
1
解决办法
2498
查看次数

如何通过iOS 7中的游戏中心应用邀请玩家?

我已经实现了自动匹配,并在具有不同游戏中心帐户的两个实际设备之间进行了测试,因此我知道我已正确设置该部分:我可以创建匹配,并在两个玩家之间发送数据.现在我正在实施邀请部分.

游戏中心编程指南 说:

当您的游戏直接从Game Center应用程序启动以主持匹配时,playersToInvite参数为非零.此参数包含一系列玩家标识符,列出要邀请参加比赛的玩家.

我不明白的是,如何通过游戏中心应用程序邀请玩家.在游戏中心应用程序中,我可以看到我的游戏.当我点击它时,在右上角有一个带文字的按钮:"...".当我点击它时,我看到两个选项:"播放"和"分享".点击"播放"即可启动我的应用.

是否有一些我需要实现的代码,Game center app以便向我提供选择朋友邀请等的选项?

编辑:这篇文章中的人似乎与我的问题几乎相同: 对于玩家托管的内容的 确切答案到目前为止还没有明确的答案,关于如何填充这些数据.

gamekit ios game-center

0
推荐指数
1
解决办法
5413
查看次数