Archive for the 'cocosLive' Category

Top Paid App is using cocos2d and cocos Live


There are a lot of games in the App Store which are using cocos2d and cocos Live:

The number of games using cocos2d / cocos Live is growing fast. At present there are more than 80 games using cocos2d and more than 30 games using cocos Live.

Also, I’ve been recently informed that the top paid application is StickWars, which uses cocos2d and cocos Live!
Congratulations to John Hartzog for his game, and to the cocos2d community!

cocoslive released under the GNU GPL v3 license

Hi,
I’ve just released cocos Live with the GNU GPL v3 license.
The project is hosted in here:
http://code.google.com/p/cocoslive/

Everybody is welcome to participate in the development of the server.
The are a lot of interesting things to do with it!

If you want to join the discussion forum, go here:
http://groups.google.com/group/cocoslive-discuss

cocos Live v0.1.1 with device id filter


Cocos Live v0.1.1 introduces some changes in the Web front end. The most important change is that now it is possible to the display certain fields in the Web and send back to the iPhone another set of fields.
Use the Sendback property to send a field back to the iPhone and use the Display On Web property to display a field on the web page.
Eg: If you don’t want to send back the usr_playername property to the iPhone, but you want to display it on the web page, then set SendBack = False and Display On Web = True.

In Cocos Live v0.1.1 you can also filter games by device id:


// request scores posted by this device
// request scores "all time"
// request best 15 scores (limit:15, offset:0)
[request requestScores:kQueryAllTime limit:15 offset:0 flags:kQueryFlagsByDevice category:@"easy"];

To filter by device id using the Web front end you need to enable the Display On Web property for the cc_device_id field.
Then, you can click on that field to filter by that device id.

Cocos Live client v0.1.1 will be available with cocos2d v0.7.1, but if you can’t wait, you can download it from the svn rev. 594.

Cocos Live service v0.1.1 is “live” now. To try this feature, you can play filtering the scores of DemoGame game.

cocos Live: a high score server for cocos2d

Cocos Live is a service that tries to help iPhone Indie Game Developers by giving them an API to solve their online requirements.

As of version 0.1, the only feature available is the High Score Server. Future versions will have more features.

To use the High Score Server you need to:

  1. Have a valid Google account
  2. Sign in into Cocos Live with that account
  3. Create a game, customize it, and copy the secret key

Requesting a score

-(void) requestScore
{
    // create a Request object for the game "DemoGame" 
    // You need to implement the Score Request Delegate
    ScoreServerRequest *request = [[ScoreServerRequest alloc] initWithGameName:@"DemoGame" delegate:self];
 
     /* use kQueryFlagIgnore to request World scores */
     tQueryFlags flags = kQueryFlagIgnore;
 
     /* or use kQueryFlagCountry to request the best scores of your country */
     // tQueryFlags flags = kQueryFlagByCountry;
 
     // request the first 15 scores ( offset:0 limit:15)
     // request AllTime best scores (this is the only supported option in v0.1
     // request the scores for the category "easy"
     [request requestScores:kQueryAllTime limit:15 offset:0 flags:flags category:@"easy"];
 
     // Release. It won't be freed from memory until the connection fails or suceeds
     [request release];
 }
 
// ScoreRequest delegate
-(void) scoreRequestOk: (id) sender
{
// the scores are stored in a NSArrayNSArray *scores = [sender parseScores];
 
 // Display them as you wish: using a UITableView,
 // a custom CocosNode, etc...
 }
 
-(void) scoreRequestFail: (id) sender
{
// request failed. Display an error message.
}

Posting a score

-(void) postScore
{
    // Create que "post" object for the game "DemoGame"
    // The gameKey is the secret key that is generated when you create you game in cocos live.
    // This secret key is used to prevent spoofing the high
    scoresScoreServerPost *server = [[ScoreServerPost alloc] initWithGameName:@"DemoGame" gameKey:@"e8e0765de336f46b17a39ad652ee4d39" delegate:self];
 
    NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:4];
 
    // usr_ are fields that can be modified.
    // set score[dict setObject: [NSNumber numberWithInt: 340 ] forKey:@"cc_score"];
    // set speed[dict setObject: [NSNumber numberWithInt: 120 ] forKey:@"usr_speed"];
    // set angle[dict setObject: [NSNumber numberWithInt: 92 ] forKey:@"usr_angle"];
    // set playername[dict setObject:@"Ricardo" forKey:@"usr_playername"];
    // set player type[dict setObject: [NSNumber numberWithInt: 0 ] forKey:@"usr_playertype"];
 
     // cc_ are fields that cannot be modified. cocos fields
     // set category... it can be "easy", "medium", whatever you want.
     [dict setObject:@"easy" forKey:@"cc_category"];
 
    [server sendScore:dict];
 
     // Release. It won't be freed from memory until the connection fails or suceeds
     [server release];
 }
 
// PostScore Delegate
-(void) scorePostOk: (id) sender
{
    // Score post successful
}
 
-(void) scorePostFail: (id) sender
{
    // score post failed
    tPostStatus status = [sender postStatus];
    if( status == kPostStatusPostFailed ) {
        // an error with the server ?
        // try again
    }else if( status == kPostStatusConnectionFailed ) {
        // a error establishing the connection ?
        // turn-on wifi, and then try again
    }
}

For further information download cocos2d for iPhone v0.7, try the cocosLiveDemo example and read the cocosLiveDemo.m file.