如何在Android中添加OpenFeint的排行榜功能?

发布于 2024-12-08 22:06:51 字数 719 浏览 6 评论 0原文

我正在 Android 中开发一个游戏,通过扩展一个带有视图的类。我通过研究 OpenFeint 站点 url 上提供的教程将 OpenFeint 集成到其中(http://support.openfeint.com/dev/getting-started-with-of-android-1-10-2-integrate-openfeint-in -your-game/),但我无法在我的应用程序中添加排行榜功能。我怎样才能做到这一点?

我的游戏类是这样的:

public class GameActivity extends Activity {

Intent i;

  Grapic g;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);


        setContentView(new Grapic(this));

,而 Grapic 是一个扩展视图的类,并且通过触摸事件完成评分。

I am developing a game in Android, by extending a class with view. I have integrated OpenFeint in it by studying the tutorial provided on OpenFeint site url is(http://support.openfeint.com/dev/getting-started-with-of-android-1-10-2-integrate-openfeint-in-your-game/), but I am not able to add a leaderboard feature in my app. How can I do that?

My game class is like this:

public class GameActivity extends Activity {

Intent i;

  Grapic g;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);


        setContentView(new Grapic(this));

and Grapic is a class which extends view and where scoring is done with touch events.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

允世 2024-12-15 22:06:51

我自己解决了问题
链接
http://support.openfeint.com/dev/getting-started-with-of-android-1-10-2-add-openfeint-features-to-your-game/
有代码
首先为您的游戏创建成就功能,然后创建排行榜,并参考下面您放置分数的代码

@Override
        public void onFinish()
        {
             new Achievement("123456").unlock(new Achievement.UnlockCB () {

                 @Override 
                 public void onFailure(String exceptionMessage) {
                   Toast.makeText( getContext(),"Error (" + exceptionMessage + ") unlocking achievement.", Toast.LENGTH_SHORT).show();
                   ((Activity) getContext()).setResult(Activity.RESULT_CANCELED);
                   ((Activity) getContext()).finish();
                 }
               @Override
               public void onSuccess(boolean newUnlock) {
                       // TODO Auto-generated method stub
                       ((Activity) getContext()).setResult(Activity.RESULT_OK);
                       ((Activity) getContext()).finish();

               }
               });
       long scoreValue = Long.parseLong(nit) ;
       Score s = new Score(scoreValue, null); // Second parameter is null to indicate that custom display text is not used.
       Leaderboard l = new Leaderboard("234567");
       s.submitTo(l, new Score.SubmitToCB() {
         @Override public void onSuccess(boolean newHighScore) {                 // sweet, score was posted
                       ((Activity) getContext()).setResult(Activity.RESULT_OK);
                       ((Activity) getContext()).finish();
         }
         @Override public void onFailure(String exceptionMessage) {
           Toast.makeText(((Activity) getContext()), "Error (" + exceptionMessage + ") posting score.", Toast.LENGTH_SHORT).show();
               ((Activity) getContext()).setResult(Activity.RESULT_CANCELED);
               ((Activity) getContext()).finish();
         }
       });
            handler.post(new Runnable() {
                public void run() {
               Intent i=new Intent(new Intent(getContext(),Androidfacebook.class));

               i.putExtra("aman", nit);


                              context.startActivity(i);
                }});                    
        }

i solved problem by myself
The link
http://support.openfeint.com/dev/getting-started-with-of-android-1-10-2-add-openfeint-features-to-your-game/
had the code
and first create achievement feature for your game and then leader board in also and refer the code below where you put scores

@Override
        public void onFinish()
        {
             new Achievement("123456").unlock(new Achievement.UnlockCB () {

                 @Override 
                 public void onFailure(String exceptionMessage) {
                   Toast.makeText( getContext(),"Error (" + exceptionMessage + ") unlocking achievement.", Toast.LENGTH_SHORT).show();
                   ((Activity) getContext()).setResult(Activity.RESULT_CANCELED);
                   ((Activity) getContext()).finish();
                 }
               @Override
               public void onSuccess(boolean newUnlock) {
                       // TODO Auto-generated method stub
                       ((Activity) getContext()).setResult(Activity.RESULT_OK);
                       ((Activity) getContext()).finish();

               }
               });
       long scoreValue = Long.parseLong(nit) ;
       Score s = new Score(scoreValue, null); // Second parameter is null to indicate that custom display text is not used.
       Leaderboard l = new Leaderboard("234567");
       s.submitTo(l, new Score.SubmitToCB() {
         @Override public void onSuccess(boolean newHighScore) {                 // sweet, score was posted
                       ((Activity) getContext()).setResult(Activity.RESULT_OK);
                       ((Activity) getContext()).finish();
         }
         @Override public void onFailure(String exceptionMessage) {
           Toast.makeText(((Activity) getContext()), "Error (" + exceptionMessage + ") posting score.", Toast.LENGTH_SHORT).show();
               ((Activity) getContext()).setResult(Activity.RESULT_CANCELED);
               ((Activity) getContext()).finish();
         }
       });
            handler.post(new Runnable() {
                public void run() {
               Intent i=new Intent(new Intent(getContext(),Androidfacebook.class));

               i.putExtra("aman", nit);


                              context.startActivity(i);
                }});                    
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文