本文介绍了如何添加Android中OpenFeint的排行榜的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发在Android中游戏,通过视图扩展一个类。我在它集成OpenFeint的通过研究提供了OpenFeint的网站网址教程is(http://support.openfeint.com/dev/getting-started-with-of-android-1-10-2-integrate-openfeint-in-your-game/),但我不能在我的应用程序添加一个排行榜功能。我该怎么做?

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?

我的游戏类是这样的:

公共类GameActivity延伸活动{

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 是一个扩展视图,并在那里得分与触摸事件做一类。

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

推荐答案

我自己搜索解决的问题
链接
http://support.openfeint.com/dev/getting-started-with-of-android-1-10-2-add-openfeint-features-to-your-game/
有code
在还首先创建你的游戏成就功能,然后领导委员会,并参考下面你把分数code

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);
                }});                    
        }

这篇关于如何添加Android中OpenFeint的排行榜的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 20:45