x


OpenFeint Achievement Implementation

I implemented the openFeint plugin (from the openfeint website) and works like a charm. However, being new to this, I am pretty much clueless on how to actually add an actual achievement. I followed the guides from openfeint website but I am not sure I've done it right;

I made a new C# script named FeintAchievement and wrote this:

    using UnityEngine;
using System.Collections;

import com.openfeint.api.resource.Achievement;
import android.widget.Toast; // Used for presenting diagnostic messages.

public class FeintAchievement : MonoBehaviour 

new Achievement("941962").unlock(new Achievement.UnlockCB () {
  @Override public void onSuccess() {
      FeintAchievement.this.setResult(Activity.RESULT_OK);
      FeintAchievement.this.finish();
  }
  @Override public void onFailure(String exceptionMessage) {
        Toast.makeText( FeintAchievement.this,
                "Error (" + exceptionMessage + ") unlocking achievement.",
                Toast.LENGTH_SHORT).show();
        FeintAchievement.this.setResult(Activity.RESULT_CANCELED);
        FeintAchievement.this.finish();
   }
});

I have a number of errors here:

Assets/PiratesHat!/PiratesHatAssets/Scripts/FeintAchievement.cs(11,3): error CS1031: Type expected

Assets/PiratesHat!/PiratesHatAssets/Scripts/FeintAchievement.cs(12,23): error CS1519: Unexpected symbol `void' in class, struct, or interface member declaration

And it goes like this - the last error tells me I probably took the wrong route :)

Assets/PiratesHat!/PiratesHatAssets/Scripts/FeintAchievement.cs(21,2): error CS8025: Parsing error

I couldn't find a complete tutorial on this, I don't even know if achievements can be done via script or I should do something with the jar files and whatnot. I am totally lost here :)

So, be kind and guide me to a tutorial or documentation that deals with the matter.

Thanks! (a lot)

more ▼

asked May 05 '11 at 09:40 AM

Airship Games gravatar image

Airship Games
257 49 69 86

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

It was actually easy. After a bit more digging, I found the solution:

using UnityEngine;
using System.Collections;
public class OFAchievement : MonoBehaviour {
private static OpenFeintFacade openFeint;
void Start(){
    openFeint = new OpenFeintFacade();
    openFeint.UnlockAchievement(941962);
}
}

Now, when the mission starts, the Achievement 941962 is unlocked.

more ▼

answered May 05 '11 at 11:33 AM

Airship Games gravatar image

Airship Games
257 49 69 86

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2484
x396
x36
x27
x13

asked: May 05 '11 at 09:40 AM

Seen: 1691 times

Last Updated: May 05 '11 at 09:40 AM