Related to the Mole Game App Source

Asked 2 years ago, Updated 2 years ago, 55 views

Press the current button (touch event) to make the start and end

I couldn't make a pause. I can't use all the functions...

Also, I want to know the restart function. Even if I search here and there, because of the limitations of my knowledge,

There's nothing I can recognize.Please. I'll leave the sauce on the bottom

public class MoleActivity extends Activity { private Handler mHandler = null; int mScore = 0; int mTime = 30; int[] imgValue = new int[9]; ImageButton[] imgMole = new ImageButton[9];

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button btnReset = (Button)findViewById(R.id.btnReset);
    final Button btnStart = (Button)findViewById(R.id.btnStart);
    final Button btnStop = (Button)findViewById(R.id.btnStop);
    final Button btnFinsh = (Button)findViewById(R.id.btnFinsh);
    final TextView  txtScore = (TextView)findViewById(R.id.txtScore);    
    final TextView  txtTime = (TextView)findViewById(R.id.txtTime);    
    imgMole[0] = (ImageButton)findViewById(R.id.imageButton1);
    imgMole[1] = (ImageButton)findViewById(R.id.imageButton2);
    imgMole[2] = (ImageButton)findViewById(R.id.imageButton3);
    imgMole[3] = (ImageButton)findViewById(R.id.imageButton4);
    imgMole[4] = (ImageButton)findViewById(R.id.imageButton5);
    imgMole[5] = (ImageButton)findViewById(R.id.imageButton6);
    imgMole[6] = (ImageButton)findViewById(R.id.imageButton7);
    imgMole[7] = (ImageButton)findViewById(R.id.imageButton8);
    imgMole[8] = (ImageButton)findViewById(R.id.imageButton9);

    btnReset.setOnClickListener(new View.OnClickListener(){
        public void onClick(View v){

        }
    });
    btnStart.setOnClickListener(new View.OnClickListener(){
        public void onClick(View v){
            mScore = 0;
            mTime = 30;
            mHandler.sendEmptyMessageDelayed(0, 1000);
            return;


        }
    });
    btnStop.setOnClickListener(new View.OnClickListener(){
        public void onClick(View v){

        }
    });
    btnFinsh.setOnClickListener(new View.OnClickListener(){
        public void onClick(View v){
                finish();
            }
    });

android-studio

2022-09-22 15:04

1 Answers

You must implement the Pause and Restart functions yourself. Just as Taewoo initializes the score and time when he clicks the Start button, clicking the Pause button means that the timer should be stopped and the code should be written so that the mole does not click. There is a simple game source code, so I attached the link.

https://github.com/danielgomezrico/FingerBoom/blob/master/FingerBoom/src/com/makingiants/fingerboom/activity/GameActivity.java

I haven't done it myself, but I think it can be a reference for implementing the function because the Pause function is implemented in the code.


2022-09-22 15:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.