我遇到了一個奇怪的問題。我試圖檢查當前時間是否大於powertimer。當我運行該方法時,即使powerup.getPowertimer() - System.currentTimeMillis()
大於0,我通過打印結果測試if語句返回true。Java if語句currentTimeMillis,檢查是否已經過了特定的時間
this.powertimer = System.currentTimeMillis() + 10000;
public long getPowertimer() {
return this.powertimer;
}
if ((powerup.getPowertimer() - System.currentTimeMillis()) > 0) {
System.out.println(powerup.getPowertimer() - System.currentTimeMillis());
powerup.reversePower(player);
expired.add(powerup);
}
有誰知道如何解決這個問題?
哇我的愚蠢misstake。像需要休息一樣。 – warbio