-
-
Save codingwithsara/40dcd0c32897e45232f3dc3e93e1d7c7 to your computer and use it in GitHub Desktop.
The Flying Bird
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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