Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GameEngine {
- // time length 20 s
- val TIME_UNIT: Long = 21000
- var timer:CountDownTimer? = null
- fun init(state: GameState){
- state.onStartEngine()
- // interval 1 s
- timer = object : CountDownTimer(TIME_UNIT, 1000){
- override fun onFinish() {
- state.onFinish()
- }
- override fun onTick(p0: Long) {
- state.onUpdate(p0)
- }
- }
- }
- fun start(){
- timer?.start()
- }
- fun stop(){
- timer?.cancel()
- }
- }
Add Comment
Please, Sign In to add comment