2

finally came to the end of cocos2d game developement, in order to get this, i'm sending totalScore to the next gameover.class activity to set as highscore if it is high and wanted to display score and playername. i have done this, but once the game is over i'm not able to get gameover.class activity, dont know where m i going wrong. please help me

this is my gameplay layer(first activity)

 if (spriteCounter<=0)
                {


                    Intent mainScore = new Intent(CCDirector.sharedDirector().getActivity(), GameOver.class);
                    mainScore.putExtra("totalscore", countScore);
                    CCDirector.sharedDirector().getActivity().startActivity(mainScore);
                    System.out.println("------------");
                    CCDirector.sharedDirector().getActivity().finish();

                 }

gameover.class (2nd activity)

public class GameOver extends MainActivity {

ImageView playagain, home;
String[] columns;
int Score = 0;
String TOTALSCORE = "score";
String PLAYERNAME = "playername";

SQLiteDatabase db;

SharedPreferences sharedPreference = CCDirector.sharedDirector()
        .getActivity().getSharedPreferences("sharedPreference", 0);

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.gameover);

    int totalscore = getIntent().getIntExtra("totalscore", -1);
    SharedPreferences sharedPreference = CCDirector.sharedDirector()
            .getActivity().getSharedPreferences("sharedPreference", 0);
    long temp_totalscore = (long) totalscore;
    try {
        String bp_totalscore = sharedPreference.getString(TOTALSCORE, null);
        String bp_playername = sharedPreference.getString(PLAYERNAME, null);
        if (totalscore > Integer.parseInt(bp_totalscore)) {

            showSettingsDialog(temp_totalscore);

        }

    } catch (Exception e) {
        showSettingsDialog(temp_totalscore);
    }

    intiatizeviews();
    viewlisteners();

}

private void showSettingsDialog(long totalscore) {
    EnterHighscore dialog = new EnterHighscore(this, totalscore);

    dialog.show();

}

private void intiatizeviews() {
    playagain = (ImageView) findViewById(R.id.playagainimageView);
    home = (ImageView) findViewById(R.id.homeimageView);

}
samm
  • 482
  • 5
  • 14

1 Answers1

0

but once the game is over i'm not able to get gameover.class activity

Assuming your problem is that while launching this new activity the application is crashing with logcat showing couldn't find the gameover class, have you registered this GameOver Activity in your manifest file?

Rajeev
  • 1,374
  • 1
  • 11
  • 18