logo
down
shadow

How to implement a leaderboard (Game Center) into project


How to implement a leaderboard (Game Center) into project

By : Roman Kinyakin
Date : November 14 2020, 04:51 PM
Hope that helps If you've actually looked this up, you will find loads of tutorials on this so I don't think you have, or you haven't really learned how to use xCode.
Here's how I'd do the code:
code :
    -(void)submitScore //submit the score to game centre
    {
        GKScore *score = [[GKScore alloc] initWithLeaderboardIdentifier:@"LeaderboardName"]; 
        int64_t GameCenterScore = Score;
        score.value = GameCenterScore;

        [GKScore reportScores:@[score] withCompletionHandler:^(NSError *error) {
            if (error != nil) {
                NSLog(@"%@", [error localizedDescription]);
            }
        }];
    }


-(void)authentication //log player into game centre
{
    GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];

    localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
        if (viewController != nil) {
            [self presentViewController:viewController animated:YES completion:nil];
        }
        else{
            if ([GKLocalPlayer localPlayer].authenticated) {
                NSLog(@"authentication succcesful");
                GameCenterAvaliable = YES;
                [[GKLocalPlayer localPlayer] loadDefaultLeaderboardIdentifierWithCompletionHandler:^(NSString *leaderboardIdentifier, NSError *error) {

                    if (error != nil) {
                        NSLog(@"%@", [error localizedDescription]);
                    }
                    else{
                        leaderboardIdentifier = leaderboardIdentifier;
                    }
                }];
            }

            else{
                NSLog(@"authentication unseuccseful");
                GameCenterAvaliable = NO;
            }
        }
    };
}

-(IBAction)ShowGameCenter:(id)sender //show game centre
{
    GKLeaderboardViewController *LeaderboardController = [[GKLeaderboardViewController alloc] init];
    if (LeaderboardController != nil) {
        LeaderboardController.leaderboardDelegate = self;
        [self presentViewController:LeaderboardController animated:YES];
    }
}

//Animate gc out if finished with it

-(void)leaderboardViewControllerDidFinish: (GKLeaderboardViewController *) viewController{
    [self dismissViewControllerAnimated:YES];
}


Share : facebook icon twitter icon
game center leaderboard integration with cocos2d game

game center leaderboard integration with cocos2d game


By : kiwifruit
Date : March 29 2020, 07:55 AM
Hope this helps I believe this is by design:
How to update score in Game Center leaderboard even if it's lower game center

How to update score in Game Center leaderboard even if it's lower game center


By : Bruce.Chan
Date : March 29 2020, 07:55 AM
wish helps you No. The scores stored for each leaderboard are the highest scores ever reported. When a score is reported that is lower than the value already stored it is ignored.
There is a context field in the GKScore object that you might store the amount of gold in but it will only be saved by Game Center when the score is higher than the previous high, so probably not what you're looking for.
Implement a Game Center leaderboard (iOS 7)

Implement a Game Center leaderboard (iOS 7)


By : Dominik
Date : March 29 2020, 07:55 AM
should help you out To create the necessary code for a leaderboard see here: Game Center in IOS 7 leaderboard
To authenticate the user you need this code:
code :
[[GCHelper sharedGameKitHelper] authenticateLocalPlayer];
How to Implement Game Center Leaderboard ID in swift

How to Implement Game Center Leaderboard ID in swift


By : user3283622
Date : March 29 2020, 07:55 AM
like below fixes the issue You can choose arbitrary (unique) strings as leaderboard IDs and assign them in iTunes Connect. Mine look like this: leaderboard.identifier = "com.domain.app.leaderboard".
Game Center Leaderboard not appearing on production version of game?

Game Center Leaderboard not appearing on production version of game?


By : Emre Y.
Date : March 29 2020, 07:55 AM
I hope this helps you . I'm not sure if this section existed before. But I needed to explicitly add my created leaderboards to my release.
Related Posts Related Posts :
  • CordovaError: Promise rejected with non-error: Error code 65
  • How to append NSMutable strings into a UILabel
  • CustomCell label value does not change
  • Display ad in iAd Bannerview iAd Network
  • Warning: "Could not get traitsetID for iPhone11,6" (Assets.xcassets)
  • Changing root view controller after iOS app has loaded.
  • SocketRocket and iOS certificate pinning
  • Draggable UIButton Snap To a Circle Path
  • Running FireBase in the background
  • resizing UIPopoverController to fit UITableController
  • UICollectionView Exception Crash
  • targeting iOS5 - will it work on iOS6 also?
  • FBLoginView get email
  • Scale UIImages height to UIImageView height
  • Creating a custom progress indicator in ios
  • NSRunLoop API difference
  • Is it possible to inject custom settings into my iOS application "Notifications" settings dialog?
  • UIAlertview not accepting string as message
  • Axis change of stackView giving layout error
  • How to use AVAssetResourceLoader?
  • How to write block definition using properties?
  • iOS connect/reconnect to Bluetooth device when using external-accessory and MFi
  • Saving XMPP Multi User chat messages through XMPP MessageArchiving in iOS
  • Deciding iOS version: pros and cons
  • iOS: Resigned app cannot access keychain through security API
  • How can I set To and Subject fields in an E-Mail being sent by UIDocumentInteractionController?
  • Updating uilabel in view controller underneath another
  • Maximum time Intervel for NSTimer
  • Delete Core Data Entry from Table View Controller
  • How to unload UIViewcontroller from memory?
  • Compressing UIImage as Far as Possible?
  • Optimizing workflow to update internally owned cocoapods dependencies?
  • Formatting an NSDate with Abbreviated Month/Day Names
  • I'm creating a quiz game with 4 answers and I want to add score
  • Tap Gesture to Hide Navigation Bar, Tab Bar, and Status Bar
  • FBSessionStateClosedLoginFailed when I am logged in through Settings
  • CGRect positioning according to center point
  • iOS: Update table view datasource with animations without core data
  • iOS : Where to start for AliPay integration?
  • Routing App Coverage File missing but not needed?
  • Drawing on a zoomable view
  • Append NSStrings and NSNumber to NSMutableArrays and make NSMutable dictionary
  • Terminating app due to uncaught exception 'NSRangeException' when calling dequeueReusableCellWithReuseIdentifier:forInde
  • Collision without physics (Cocos2D + Box2D iOS)
  • Creating a percentage based iOS layout
  • Update tableView row from AppDelegate Swift 4
  • Assigning return value of a class method to a variable error
  • how to display circular progress in delphi ios apps?
  • I can't figure how to fix this Expected identifier or '('
  • How to Test APIs in Swift 4?
  • Link error /Build/Products/Debug-iphonesimulator file not found
  • working with a very large JSON object in iOS
  • Turn off part of the iPhone Screen
  • Phonegap 3.0 app with facebook login using xCode
  • How to add interstitial admob ads to my ios project
  • adding tapku calendar to ios app
  • Add an alertcontroller in a global swift file?
  • Take square image with Cordova (Phonegap) Camera API?
  • Amazon S3 policy allowing only upload not overwrite
  • How to change the UILabel content by tapping?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org