Dec 082012
 

Background

I received an email on 11-Nov-2012 stating that OpenFeint will be discontinued in about a month.  That’s not a lot of time to research alternatives, code, test, and publish an update to existing apps that utilize that service.  I wish the announcement came a bit sooner.

Since I am using CoronaSDK, OpenFeint was easy to implement.  Another solution will require a bit more work, since there are no other integrated libraries for Android devices to handle leaderboards and achievements.  Game Minion seems to be a very nice alternative, but at this time, it is lacking a bit in documentation and sample apps, so working through implementation requires a lot of testing.

In this article, I am going to document my attempt to integrate Game Minion into my existing app, Spell Them Out, using the Facebook login feature.  Further articles will outline specific features I am implementing.

This demo will log into Facebook to grab the appropriate info needed to pass to Game Minion.  Each step will display some text on your device.

First Steps

A few things before you start coding… In order to test this…

Step 1 – Setup

local gm = require "gameminion"
local json = require("json")
local facebook = require "facebook"

local FACEBOOK_APPID = "XXXXXXXXXXXXXXXXX"   -- your app's fb id
local GM_ACCESSKEY = "XXXXXXXXXXXXXXXXXXX"   -- your app's Game Minion Access Key
local GM_SECRETKEY = "XXXXXXXXXXXXXXXXXXX"   -- your app's Game Minion Secret Key
local returnToken, returnID -- stores needed facebook info

local GMLoginListener  -- Game Minion Listener
local fbListener       -- Facebook Listener
local StartDemo
local EndDemo

Basic stuff, declare the required libraries, variables, and functions.  You will need to enter your app’s info where indicated above.

Step 2 – Start  function

function StartDemo()
    Runtime:addEventListener( "LoggedIn", GMLoginListener )
    Runtime:addEventListener( "LoginError", GMLoginListener )

    gm = gm.init(GM_ACCESSKEY, GM_SECRETKEY)
    facebook.login(FACEBOOK_APPID, fbListener, {"publish_stream", "email"})
end

StartDemo will be called to kick off all of this.  In that function, start the event listeners needed for Game Minion, and then call gm.init, passing the Access Key and Secret Key provided by Game Minion when you added your app on their portal.

At this point, log into facebook, using your app’s ID, and identify the listener to receive facebook notification.  Notice the “email” permission?  That is required in order to pass info to Game Minion later.  Be sure to add this permission to your app on the Facebook portal as well.

Step 3 – Create the Facebook Listener

function fbListener(event)
    local function onComplete(event)
        if event.action == "clicked" then
            if event.index == 2 then
                facebook.login(FACEBOOK_APPID, fbListener, {"publish_stream", "email"})
            end
        end
        return true
    end

    local alert

    if event.type == "session" then
        if event.phase == "login" then
            display.newText("1. Facebook Login Successful", 0, 0, native.systemFont, 12)
            returnToken = event.token
            facebook.request( "me" )
        elseif event.phase == "loginFailed" or event.phase == "loginCancelled" then
            display.newText("1. Facebook Login Failed", 0, 0, native.systemFont, 12)
            alert = native.showAlert("Facebook Login Error", 
               event.response, { "Cancel", "Try Again" }, onComplete)
        end
    elseif event.type == "request" then
        if event.isError then
            display.newText("2. Facebook Request Failed", 0, 20, native.systemFont, 12)
        else
            display.newText("2. Facebook Request Successful", 0, 20, native.systemFont, 12)
            local response = json.decode( event.response )
            gm:loginFacebook(response["id"], returnToken)
        end
    end
end

The facebook login call will return an event type of “session”, so we check to see if login was successful or if there was a failure.  Failure will pop up a dialog box and ask the user to try again.

If successful, you need to store the event.token that is returned at this point (line 16).  We will need this later.  The token is only returned in the login phase, so we have to store it for now.

Now, you need to get the user’s Facebook ID, so we call facebook.request() with the “me” parameter (line 17).  This will return a JSON string, and once we receive an event type of “request”, we can decode the JSON string returned in event.response.  Once the string has been decoded, the user’s ID is available for use.  I decode the JSON string to a variable named response, and the ID field needed is now located in response["id"].

We now have all the info needed to log into Game Minion (user’s ID and the access token).  Call the loginFacebook() function with these parameters.  Game Minion’s event listener will be triggered when the login procedure is complete.

Step 4 – Game Minion Listener events

function GMLoginListener(event)
    if (event.errorMsg ~= nil) then
        display.newText("3. Game Minion Login Filed", 0, 40, native.systemFont, 12)
        local alert = native.showAlert("Game Minion Login Error", event.response, { "Cancel"})
    else
        display.newText("3. Game Minion Login Successful", 0, 40, native.systemFont, 12)
        local alert = native.showAlert("Login Success!", "Logged into Game Minion", { "OK" })
    end

    EndProg()       -- demo complete, clean up
    return true
end

If everything works as planned, you will have successfully logged into Game Minion, and there will be no errors. In the event there is a problem, event.errorMsg will have some meaningful info, which you can then display or parse to determine what happened.  My GM Listener function above is very generic, but once you get a successful login, do what you need to do in your app.  I am just displaying a message and exiting.

Result

Game Minion Demo - Step 1

The image on the left is a shot of my Android phone with a successful login.  The step step will be the addition of leaderboards and trophies.  I am not sure what I will handle next, but I will post another article detailing whatever I decided to cover.

Let me know what you think of this article, and how you are doing with your Game Minion integration.  Remember, I am learning as I go, so some things may change.

Want to download a copy of the code?

 

 

Oct 022012
 

The day iOS6 became available, I updated my 3rd Gen iPad, which is a pretty unusual thing for me to do.  I generally like to let large system updates settle down a bit before I attempt an update to a device that I use a lot.  I never install a Windows Service Pack on the first day (let alone, the first month!), and when the latest Android update comes out for my phone, I tend to read up on what to expect.  For whatever reason, I threw caution to the wind and clicked the Install button.

The following is a short list of things I am finding a bit frustrating.  Yes, I think we all know about the maps issue, and the lack of a YouTube app, so I will not include them in my personal frustration list.  These are apps that will eventually get there anyway.

Wi-Fi Issue

I am experiencing a wi-fi issue.  I see that I am not the only one.  iOS5 never had an issue with dropping connection to my home network, but iOS6 just feels like dropping whenever it wants to.  Not sure why, but other devices sitting right next to me are functional when this happens, so I am sure it is not on my end.  I have to turn off wi-fi, wait, turn it back on, and hope that my iPad discovers my network.  Discovery can take several attempts as well.  Luckily, I don’t have the grayed out wi-fi toggle issue, so there’s that!

Unresponsive Touches

Has anyone experienced this?  I don’t recall reading it anywhere else (although I didn’t do an exhaustive search).  Touch an on-screen button or link and nothing happens, although it appears to have worked… the button depresses or the link highlights, but nothing happens.  Touch again.  And again.  Maybe one more time.  Three or four long touches, and then it continues on its way.

Since it appears to have registered the touch on the first attempt, I sit there thinking whether or not it actually worked, so I’ll touch again just to be sure.  Then another page will load since I touched something on the page that was just starting to display.  D’oh!

Screen Fade

Here’s another problem I have that I cannot seem to find anyone else experiencing.  Notice when you don’t touch your iPad (I guess iPhone as well… not sure), it starts to dim?  Nice feature.  Now, though, if I touch the screen while the iPad is dimming, it stops dimming, but never regains the brightness I have it configured for.  Ever.  Some times, I can’t read the screen since it is so dark, so I have to turn if off or wait until it totally dims to black, then press the home key to get my configured brightness.

Conclusion

I never expected perfection, and it was nice to see Apple CEO Tim Cook actually admit to some shortcomings with the maps, so I am not flipping out mad, but the wi-fi issue is somewhat frustrating.  Let’s hope for a small update to come along (sooner than later) that will fix these iOS6 issues.

 Posted by at 11:05 pm
Sep 032012
 

It hit me the other day… I’ve been programming for close to 35 years. That’s a long time.  That’s a long time to be doing anything as a matter of fact. During that time, there has been so many changes, so many platforms, so many tools, methodologies… It’s a constant learning experience that keeps it fun and interesting.

I spent only about 5 years programming “professionally”.  I developed database and robotics software for a laboratory division within a large insurance company.  Cool stuff, but the nine-to-five, day-in, day-out grind got old fast.

The other 30 years were stuff I wanted to do for platforms I wanted to develop for. I never put out that “killer app” that would throw me into fame and fortune, but I am hopeful that can still happen (in other words… I still have a day job).  I’ve had some moments of success and appreciation when you find out that something you created is being used by others.

Songanizer for DOS

Songanizer for DOS

There is also some stuff that never made it to market, either because I didn’t think it was good enough or because someone else thought it wasn’t good enough.

Here’s a quick look back at some of the stuff that failed to make a market impact for one reason or another, but helped shape me as a developer.

Way back in the late 1970s I developed an educational game for the Atari 8 bit line of computers. That app was rejected by the Atari Program Exchange… twice! Looking back at it now, it was an awful program, but at the time I could not understand the rejection.

In 1992 I developed “Songanizer”, a music database. First released for DOS during a time when people were moving to Windows, it didn’t do so well.  Great timing on my part, but the Windows version is largely forgotten as well.  For the few that actually bought it, it was greatly appreciated… a large data store, fast access.  I actually received an email a while back from someone still using it… 20 years later.  Pretty cool.

I also spent a few years developing applications supporting a popular BBS software package until this thing called “the internet” took off and BBSs died.  Once again, timing is everything, but a great experience.

Candlelight Favorites Inspector

Candlelight Favorites Inspector

My most “popular” app, “Favorites Inspector”, was released in 2002. I spent 10 years supporting and updating it. A modicum of success, a small blurb appeared in PC Magazine, and the next couple of months, sales were great. Unfortunately, fame was short-lived, but this was an app I was proud of, and was constantly pushing the limits of Visual Basic 6 to enhance the product.

In 2008 I spent an entire year learning game programming for Windows using XNA and C#.  The result was “Diamond Mine Mixup”which is very similar to my current title “Spell Them Out” currently on mobile platforms. The app was rejected by a known distributor (that shall remain nameless). Totally discouraged that I spent a year on this, and seeing little potential of it making it in the market, it sits on my hard drive and was never released.  A screenshot of Diamond Mine, you ask?  Well, perhaps in another post.

I guess after all of this, I could of just given up and hung up the ‘ol keyboard and compiler.

The point of this post is not to look for pity. Pity doesn’t keep you going year after year.  Rather, it is that in each case, it was a learning experience. In order to succeed, you have to fail.  If it were not for Diamond Mine Mix-up‘s failure to make it to market and all the experience that went along with its development, Spell Them Out would probably not have been released.  Now that Spell Them Out has been released and is slowing churning away in the various app stores (pennies are rolling in!), the lessons learned there will help me make my next release better.

Entry into mobile development is getting easier, and everyone thinks they have the next big money maker. Many find that it’s just as hard as any other endeavor.  For those that feel like it is a losing battle, my only advice is if you love what you are doing, then keep going despite the lack or fame or financial rewards.  Maybe it will come later.  Maybe it won’t, but giving up won’t help.  Count every step of the way as a learning experience for your next project, and if you do, it cannot be considered a failure.

 Posted by at 3:52 pm
Mar 012012
 

Spell Them Out was released to the Android Market on February 26, 2012.  Personally, it was a great sense of accomplishment since I have been trying to get this game out for a while (perhaps the topic of another post).  It wasn’t until I discovered the Corona SDK that this became a reality.  Development time from start to release was under 2 months.

In these past two months, I learned a lot about developing and releasing a game.  I also know there’s a lot to learn going forward.  A few musings:

  1. I discovered Corona some time in June of 2011 when I was starting to develop my game.  At the time, I was using the Android API, and decided to continue down that path since I had some time invested in it.  About 6 months later, I was thinking about a possible iOS release.  I also looked at my Java code and discovered that after 6 months of development, I was nowhere near complete, I remembered Corona and decided to jump in.  I started January 1, 2012, and released to the Market on February 26, 2012.
  2. I was a bit hesitant about learning yet another language, but Lua is something that can be picked up so easily.  After a couple of days, I felt very comfortable with it.
  3. I spent more time than I thought I would getting my graphics to a point where I was satisfied.  I found a few good sites for free images, and the rest I did myself. Since I was not really sure what I wanted or how I needed them created, I was not comfortable hiring someone for this project.  Spell Them Out does not require complicated images, but for future games, I will consider help in this area.  Graphics is not my specialty, but I believe I now know what to ask for and how to ask it.
  4. Marketing.  Wow, lots of work.  More work than coding.  I am sure I am not doing a great job at this, and I would rather code some more, but once your app is released, it would be great if people knew about it.  Definitely a learning experience.

I look forward to releasing Spell Them Out for iOS.  Nook and Kindle versions are in progress of approval as well.  After that, time to start another game!

 Posted by at 10:56 am