📄 stringtimer.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: StringTimer.java
import java.io.PrintStream;
import java.util.Timer;
import java.util.TimerTask;
public class StringTimer
{
private GameScreen gameScreen;
private int currentTime;
private Timer t;
private TimerTask task;
boolean running;
boolean paused;
public StringTimer(int startTime, GameScreen gameScreen)
{
this.gameScreen = null;
running = false;
paused = false;
currentTime = startTime;
this.gameScreen = gameScreen;
}
public void start()
{
running = true;
task = new TimerTask() {
public void run()
{
dec();
}
};
t = new Timer();
t.scheduleAtFixedRate(task, 100L, 100L);
}
public boolean timesUp()
{
return currentTime <= 0;
}
public void dec()
{
if(currentTime >= 0)
{
if(currentTime >= 10000 && currentTime <= 10100 && Resources.withSound)
gameScreen.countdownPlay();
currentTime -= 100;
if(currentTime == 0)
System.out.println("------Time is Zero");
} else
{
t.cancel();
t = null;
System.gc();
}
}
public void pause()
{
t.cancel();
paused = true;
}
public int getTimeInSeconds()
{
return currentTime / 1000;
}
public int getTime()
{
return currentTime;
}
public boolean isRunning()
{
return running;
}
public void resume()
{
paused = false;
task = new TimerTask() {
public void run()
{
dec();
}
};
t = new Timer();
t.scheduleAtFixedRate(task, 100L, 100L);
}
public String toString()
{
if(currentTime >= 0)
{
int time = currentTime;
String out = "";
int min = time / 60000;
time -= min * 60000;
int sec = time / 1000;
int milli = time % 1000;
if(min < 10)
out = out + "0";
out = out + min + ":";
if(sec < 10)
out = out + "0";
out = out + sec + "." + milli / 100;
return out;
} else
{
return "00:00.0";
}
}
public void DEBUG(String s, String s1)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -