skip to Main Content

I am currently doing a basic Whack a Mole game on Android Studios for a school project. I got everything pretty much working, including the moles moving up, and down when clicked.
The problem is whenever a game is ended and I choose to "play again" the game activity starts again with the timer and everything, but the mole animation no longer works.

Whenever the game ends I change activity to a game_over activity where the user can choose to play again or return to the main menu.
This is all I am doing to change activity:

public void change_to_game_over_activity()
    {
        Intent intent = new Intent(Game_Activity.this, Game_Over_Activity.class);
        startActivity(intent);
    }

I am guessing I am not properly ending the animation when changing activities because I thought when the user presses play again, the activity was going to start everything from zero.

What functions can I use to properly transition to the game_over activity and back again to the game activity if the user chooses to?

Thanks in advance for your help.

2

Answers


  1. Chosen as BEST ANSWER

    Fixed by calling finish(), and clearing all the arrays containing the mole images when on the onStop() callback.


  2. did you add this autoplay=ture in xml?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search