Skip to content

Instantly share code, notes, and snippets.

@codingwithsara
Created September 20, 2020 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingwithsara/40dcd0c32897e45232f3dc3e93e1d7c7 to your computer and use it in GitHub Desktop.
Save codingwithsara/40dcd0c32897e45232f3dc3e93e1d7c7 to your computer and use it in GitHub Desktop.
The Flying Bird
package com.codingwithsara.theflyingbird;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.util.Timer;
import java.util.TimerTask;
public class MainActivity extends AppCompatActivity {
private GameView gameView;
private Handler handler = new Handler();
private final static long TIMER_INTERVAL = 30;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
gameView = new GameView(this);
setContentView(gameView);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
handler.post(new Runnable() {
@Override
public void run() {
gameView.invalidate();
}
});
}
}, 0, TIMER_INTERVAL);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment