I am trying to use requestRankForScore but have not had any luck in getting it to work. If someone out there is using this function and would like to supply a code snippet of how they got it to work in their app I would greatly appreciate it.
Thanks
A fast, easy to use, free, and community supported 2D game engine
I am trying to use requestRankForScore but have not had any luck in getting it to work. If someone out there is using this function and would like to supply a code snippet of how they got it to work in their app I would greatly appreciate it.
Thanks
I've never used CocosLive, but I skimmed through it real quick and looks like you have to do the following:
When you call the requestRankForScore method, it'll take care of the connection in the background and then once ready, call a delegate method for you to then do whatever processing you wish. Try implementing the -(void) scoreRequestRankOk:(id) sender delegate method. Within it, you can grab the rank using [sender parseRank] which will return an int representing the rank (int rank = [sender parseRank];"
Also, as a side note, looks like you can access the rank after a score is posted as well. In a similar manner to above, when you call one of the submitscore methods, it will call the -(void) scorePostOk: (id) sender delegate method from which you can grab the rank and display it. An example of this is in the cocosLive test included with the Cocos2d download. Just thought I'd mention this in case this is what you were trying to do in your app.
- kalx
requestRankForScore seems to give me erroneous results sometimes, i think especially if the number of scores are low.
however, all it takes is a look at the demo code contained within cocos to see how it should be done!
Yep, using it like you described...
-(void)RequestRank
{
ScoreServerRequest *request = [[ScoreServerRequest alloc] initWithGameName:@"APT" delegate:self];
NSString *cat = @"10 Rounds";
switch([GlobalDataManager sharedDataManager].gametype)
{
case 1:
cat = @"10 Rounds";
break;
case 2:
cat = @"20 Rounds";
break;
case 3:
cat = @"40 Rounds";
break;
}
// Get rank of current score for display, before saving
[request requestRankForScore:[GlobalDataManager sharedDataManager].playerScore andCategory:cat];
[request release];
}
-(void)scoreRequestRankOk:(id)sender
{
int rank = [sender parseRank];
lbl_Rank.text = [NSString stringWithFormat:@"%@%d%@%d", @"Score: ", [GlobalDataManager sharedDataManager].playerScore, @" Rank: ", rank];
}
Right now I'm only testing this out on a single device. So if there are erroneous results with low scores etc then that might be it. It would be nice to know how to test this out though. I'll throw some other devices at it and see what happens then. Thanks for the feedback.
in my experience it starts to work as soon as there are a couple of scores up, no matter if they are from same device.
You must log in to post.