Dec 192010
 

As of December 2010 part 1 of my OpenFeint tutorial is no longer valid. This tutorial replaces it and will show you how to get OpenFeint working in your iPhone app.

Obviously with the new SDK things have changed. My old tutorials for OpenFeint and Facebook are now useless – but never fear! Despite it being the 19th of December and there being less than a week until Christmas, I am planning to post new tutorials for both OpenFeint and Facebook before Christmas day.

Parts 2 and 3 (achievements and leaderboards) of my OpenFeint tutorial are still valid. What has changed is how we set up and initiate OpenFeint – which was part 1. The following will get you up and running again.

Let’s get started as I really must get back to cleaning, wrapping and trying to find something thoughtful to write in my De Facto Mother in law’s card to make up for the fact I was too broke to buy her a very nice gift.

STEP ONE: Open your main.lua file or, if you are using director, open menu.lua or whatever your first game screen/scene is. Remove any old code relating to OpenFeint, except that linked to a button. If you have a button to launch the dashboard, leave it be, it will work again when we’re done. (If you are adding OpenFeint for the first time, simply open the file relating to the first screen/scene in your app.)

STEP TWO: Copy and paste the below code near the start of the file. (I place it immediately below any code relating to director.)

1
2
3
4
5
6
7
8
9
10
11
--------------------------------------------------------------------------
local openfeint = require "openfeint"

local of_product_key = "yourkey"
local of_product_secret = "yoursecret"
local of_app_id = "yourappid"
local display_name = "Your App Name"

openfeint.init ("yourkey", "yoursecret", "Your App Name", "yourappid")
openfeint.launchDashboard ()
--> Sets OpenFeint up

STEP THREE: Go to the OpenFeint Website and get your app’s information. Use it to replace all of the writing in green above. Keep the quotes in, removing them will break the code.

STEP FOUR: For those of you who need to know how to set up a button to launch the dashboard, this code will do it (assuming you already have a button named openfeintbutton);

1
2
3
4
5
6
local function opendash (event)
if event.phase == "ended" then
openfeint.launchDashboard()
end
end
openfeintbutton:addEventListener("touch", opendash)

IN CLOSING: There have been some changes made but they are easy to accommodate for. Parts 2 and 3 of the OpenFeint Tutorial remain the same.

Part 2: Adding OpenFeint Leaderboards to your App

Part 3: Adding OpenFeint Achievements to your App

And that’s it!

I hope this helps everyone get OpenFeint working again. Hopefully I’ll have a Facebook Tutorial up on Tuesday, depending on how I feel after visiting the dentist. (That’s right, I’m going to attempt to write it after getting home from the dentist – the things I do for you people!)

Peach Pellen o<[]=]

Like this post? Subscribe to the monthly newsletter!

 

  8 Responses to “Adding OpenFeint – Updated”

  1. What is .lua? Does this work in ios xcode classes?

  2. I fixed , I delete the first , openfeint.launchDashboard()

    because every time that I launch my game it show up,

    it work perfect now, but still 3 step I will do it later

    thx

  3. Openfeint.init initiates Openfeint, in my games it launches the first time I run it immediately, too. That is intentional.

    Are you calling init or launching the dashboard multiple times?

  4. I did the same in step 1 ,

    everything doing great, but when I launch my game the Openfeint screen show up before I press the button

    and when I play my game and go to the first page , it does the same,

    how can I do like what you did in ur game , that when I press the button of opienfeint only I can go to the openfeint board ?

  5. [...] integration with Facebook and OpenFeint (and now Game Center through the OpenFeint system) are great ways to add even more dimension to [...]

  6. [...] THIS IS NOW OUT-DATED. PART 2 AND 3 ARE UP TO DATE AND WORKING, BUT RATHER THAN USING THIS TUTORIAL …. [...]

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.