Created
March 17, 2012 01:25
-
-
Save thesven/2054145 to your computer and use it in GitHub Desktop.
PlayN Timer
This file contains hidden or 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.thesven.game.core.time; | |
import static playn.core.PlayN.*; | |
import playn.core.util.Callback; | |
public class Time { | |
public boolean running = false; | |
private double startTime; | |
private double elapseTime; | |
private double endTime; | |
private Callback<String> timerCallback; | |
public Time(double waitTime, Callback<String> callback) { | |
elapseTime = waitTime; | |
timerCallback = callback; | |
} | |
public void start(){ | |
startTime = currentTime(); | |
endTime = startTime + elapseTime; | |
running = true; | |
} | |
public void update(float delta) { | |
if(running){ | |
if(currentTime() >= endTime){ | |
running = false; | |
timerCallback.onSuccess("Time has elapsed"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment