0

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

我的游戏课是这样的:

公共类 GameActivity 扩展 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是一个扩展视图并且通过触摸事件完成评分的类。

4

1 回答 1

2

我自己解决了问题
链接 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);
                }});                    
        }
于 2011-10-11T11:30:01.563 回答