cocos2d-androidのゲームアプリで条件を設定したところ、条件=0の場合、現在のゲームレイヤーのスコアがハイスコアとしてGameover.classに表示されるのですが、ここで条件が0になると次のレイヤーが取得できなくなりますハイスコアとプレイヤー名を保存するオプションを表示する (Gameover.class)。
if (Counter<=0)
{
Intent mainScore = new Intent(CCDirector
.sharedDirector().getActivity(), GameOver.class);
mainScore.putExtra("totalscore", countScore);
CCDirector.sharedDirector().getActivity()
.startActivity(mainScore);
System.out.println("intent");
CCDirector.sharedDirector().getActivity().finish();
}
上記のコードを使用しましたが、print ステートメントが取得されません。この行CCDirector.sharedDirector().getActivity()
.startActivity(mainScore);
に問題があると思います。誰かこの問題を解決できますか?
これが Gameover.class です
public class GameOver extends BaseActivity {
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();
}