[box type=”info”] Edit: I’ve created another writeup on integrating GREE with cocos2d , read it here ![/box]
Hey Geeks !
So , if you’re a game developer, you’ve probably heard the news, GREE is out, OpenFeint is dead, you went to get started, and found out it has worse documentation than OpenFeint and probably couldn’t compile it !
I took the time to play around with it, and this is a little writeup on how I registered the test app on the developer panel, and compiled the test app and made it work.
NOTE: If this post gets enough attention, I’ll also show you how to integrate it with Cocos2d and add leaderboards/achievements to your Cocos2d game and migrate from OpenFeint AND show you how it works with GameCenter, just let me know in the comments, I’ll also include a downloadable project for your convenience 🙂
So, let’s begin, you’ll need to have the following before starting
- XCode 4.2 or above
- iOS 4.0 or above (GREE won’t work on devices below 4.0, BOO…)
- The iOS SDK
- A developer account on GREE
- Head to the SandBox tab, and click on Test Application and add a new app.
- Choose iOS SDK, since we’re building an iOS app 🙂
- Next step is to choose the default languages, select English (US), then click Next
- You can Ignore the Gadget.xml part (this is used when you want to log game lifecycle events)
- Select (again) English as the default language
- Choose App name (I used MyAmazingGame), if yours isn’t amazing, just call it (MyGame)
- Congrats, your test app is now added, you’ll be taken back to a table that shows your current apps, yours should be there now
- Click the (Detail) button next to your app then Copy the “AppId”, “Consumer key” and “Consumer secret” and put them in a text file or something, we’ll need that later.
- Now you’ll need to create at least one test account (Not required though, but I strongly recommend it to be able to test all GREE’s features!).
- Head again to the Sandbox tab, and click “Test Accounts”
- Go ahead, Add a new user
- Fill in the user’s data (any bogus email and username/password will do) then register !
- But Wait, The user isn’t active yet, you need to click on the link where it says “Click here to complete the account”, Don’t even ask me why, they require that step to be a pain in the ass i guess !
- You’ll get a light window with an ugly link in it, click that link (in a new window/tab)
- Congrats, your test account has now been verified to be a … fake one?? who cares !
- Go back the test accounts page and make sure your user was registered, it should look like this
- (Optional) you can add a leader board since you’r here already to give us something to tinker with !
- Back to your sandbox app list, click your app and scroll down, Click on Add next to LeaderBoard
- Click on Register LeaderBoard
- Leave default settings unless you need something different.
- Choose a name for your new leader board, also choose the type of scores it’ll be holding under Score Format, add something like “Seconds”, “Stars”, “Coins”, “Points”, etc..
- Add a language to your leader board (English ?)
- Now submit, and enjoy the job you’ve done so far !
NSDictionary* settings = [NSDictionary dictionaryWithObjectsAndKeys:
Remove it and paste this one instead:
NSDictionary* settings = [NSDictionary dictionaryWithObjectsAndKeys: GreeDevelopmentModeSandbox, GreeSettingDevelopmentMode, [NSNumber numberWithBool:NO], GreeSettingUseWallet, [NSNumber numberWithBool:YES], GreeSettingEnableGrade0, nil];
So what happened here ?, we’ve setup an NSDictionary called settings, which we will feed to the GREE class later, this holds the settings that we want GREE to use.
GreeSettingDevelopmentMode is now set to GreeDevelopmentModeSandbox which tells the SDK we’re running a test application so it won’t use the productions servers !
NOTE: if you did like me and set it to @”develop” or @”developSandbox” you’ll get this error:
"Must specify a serverUrl suffix if you are using development mode: develop or developSandbox"
Just a tip cause it got me scratching my head for a little while 😉
GreeSettingUseWallet is now set to NO, this disable the use of currency and all that other in-app purchase blood sucking features.. I hate them !
IMPORTANT: GreeSettingEnableGrade0 is now set to YES, This enables the users to run your app without being FORCED to register !, if you set this to NO the players won’t be able to use your app without registering and logging into GREE, totally not recommended !
Now we’ve got our settings straight (there are way more but those are enough for a basic setup)
Now we’ll add our app ID and Consumer Key, etc..
a few lines below settings, you’ll find this
//print encrypted strings to console [GreePlatform printEncryptedStringWithConsumerKey: consumerSecret: scramble:]
You can comment that line out or fill it in with the data we saved earlier, this is simply a debug line that prints out the encoded data to your console..
[GreePlatform initializeWithApplicationId:@"14587" consumerKey:@"c03d99c0fc77" consumerSecret:@"f9a7bb03e4cbc784b609af29c560e87c" settings:settings delegate:self];
Fill in with your own data that you saved earlier (Those are just my test data)
Now you’re set to go !, build and run your code, should run without any hassles !
GREE will now popup just like OpenFeint used to, asking the user to play with GREE, hit play (Notice you can also hit the X button to close the window and disable GREE)
Hit Play, and login using the test account we made earlier !
Now it’s all on you pirate !, check around and get acquainted with GREE!
Go out and check the Leaderboards, you’ll notice the one we created in the Portal earlier is now there, add stuff to it and experiment how things work !
BTW, I don’t really like it, but let’s see where it goes !