gamekit

How to send an NSDictionary (or plist file) as NSData using GameKit bluetooth?

久未见 提交于 2019-12-13 06:48:52
问题 I'm trying to use [currentSession sendDataToAllPeers:data withDataMode:GKSendDataReliable error:nil]; to send an NSDictionary (or a plist file) containing data from 1 device to another, and - (void)receiveData:(NSData *)data fromPeer:(NSString *)peer inSession:(GKSession *)session context:(void *)context to receive it. How can I convert to and from NSData for this to happen? 回答1: You can use the following to transform Plist to NSData: + (NSData *)dataWithPropertyList:(id)plist format:

score submittion failure

我只是一个虾纸丫 提交于 2019-12-13 05:15:22
问题 I am receiving always a Failure in my cocos2d, but when I run this project in my view based application then it will give me success, and the score will easily submitted [[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

Implementing GameKit.framework on OSX, cannot authenticate localPlayer

◇◆丶佛笑我妖孽 提交于 2019-12-13 04:32:48
问题 I'm attempting to implement GameKit in my OSX game. Unfortunately I can't find much information about how to do this; all tutorials seem to be iOS (though the documentation clearly states "Game Center is available on iOS and OS X"). Everything is compiling fine; the problem comes when I try to authenticate the local user: [[GKLocalPlayer localPlayer] setAuthenticateHandler:^(id viewController, NSError *error) { if(error) { DLog(@"Error: %@",error);// This is always returning an error } else

GameKit GKMatchMaker inviteHandler deprecated in iOS7, what is the replacement?

房东的猫 提交于 2019-12-12 15:13:27
问题 [GKMatchmaker sharedMatchmaker].inviteHandler is deprecated in iOS 7, yet the GameKit guides still say to set it up that way. Does anyone know what we're supposed to be using for iOS 7 real time game invites? There are new classes / methods for several listener classes, but none address this specifically that I have seen. 'inviteHandler' is deprecated: first deprecated in iOS 7.0 回答1: It looks like the intended replacement is the GKInviteEventListener protocol. You can see a reference to it

swift 3 gamecenter: number of participants are always 4

╄→гoц情女王★ 提交于 2019-12-12 11:35:17
问题 I made a TurnBased game that was working perfectly with swift 2. I could successfully change the code to swift 3.2 and correct all the errors about 400, but there is one issue with the game centre that I can not figure out how to fix it. When through gamecenter viewcontroler I set the number of the participant to “2Player” and then push “Invite Friends” the number of Player that I get is 4 instead of 2! the gamecenter send a text message to the next participant in which the number of

load Game Center friends and their scores into UITableView

别说谁变了你拦得住时间么 提交于 2019-12-12 09:23:54
问题 So I was wondering after reading the apple docs(https://developer.apple.com/library/ios/documentation/GameKit/Reference/GKLeaderboard_Ref/Reference/Reference.html#//apple_ref/occ/instp/GKLeaderboard/category) how would one create a UITableView and fill it with the localPlayers Game Center friends and there scores in a specific leaderboard. I know how to get the friends list and friends scores individually by using the loadScoresWithCompletionHandler: method. Edit: So far I got this to get

Apple gamecenter available test returns YES on iphone 3g

若如初见. 提交于 2019-12-12 05:59:52
问题 I'm making a game with gamecenter support. I want to diable a button for iPhone 3g or older devices. But my 3g test device says, that gamecenter is available and the matchmaking view show up. The user will never get authenticated. I use the snippet from apple to check, if gamecenter is available. It should return NO on devices older than 3gs -(BOOL)isGameCenterAvailable { // check for presence of GKLocalPlayer API Class gcClass = (NSClassFromString(@"GKLocalPlayer")); // check if the device

Sending data error?

五迷三道 提交于 2019-12-11 23:39:56
问题 typedef struct _protocol1 { int type; CGPoint pos; } Protocol1; -(void)sendData { NSError *error; Protocol1 msg; msg.pos = ccp(100,100); msg.type = 1; NSData *packet = [NSData dataWithBytes:&msg length:sizeof(Protocol1)]; [self.myMatch sendDataToAllPlayers: packet withDataMode: GKMatchSendDataReliable error:&error]; if (error != nil) { NSLog(@"error"]); } } That is a chunk of code from my project. And I'm getting an error. However, I am unsure how to retrieve more information to help me debug

How to implement a Best Score Today leaderboard using Game Center?

こ雲淡風輕ζ 提交于 2019-12-11 12:37:10
问题 I want to create a leaderboard in Game Center for the best scores submitted today, and I want it reset every day at midnight. It's not hard to just create a "most recent score" leaderboard and keep track of the score for the day in the app and submit it, however my concern is that users who do not launch the app the next day will have an old score which remains in the "best score today" board until they launch it. Is there any way to make scores expire, or only show the current scores for the

GKGraph Incorrectly Calculates Path with GKGraphNode2D-Subclassed Nodes

二次信任 提交于 2019-12-11 10:07:41
问题 I started investigating this issue with this question which was partially resolved in the iOS 9.2 SDK. However, upon further investigation, I realized that this framework was still not working as expected. In summary, a GKGraph can be constructed with nodes ( GKGraphNode and its subclasses), between which pathfinding costs and paths can be calculated. A GKGraphNode2D is simply a GKGraphNode that sits on and encapsulates its coordinates in a two-dimensional grid. GKGraphNode can be subclassed,