私はここで多くの投稿を調べましたが、必要な解決策を完全に見つけることができませんでした...
エラーが発生しました:
the method initTimer(untitled.Object, String, int int) in the type untitled.TimerClass is not applicable for the arguments (untitled.Toon, String, int, int)
そしてそれは私を夢中にさせています。
timers.initTimer(character, "regenAdd", 0,3);
上記の行はエラーをスローする行であり、次の行は関数です。
public void initTimer(final Object obj, final String method, int delay, int period) {
delay*=1000;
period*=1000;
final Class<?> unknown = obj.getClass();
new Timer().schedule(new TimerTask() {
public void run() {
try {
//get the method from the class
Method whatToDo = unknown.getMethod(method, null);
try {
//invoke() the object method
whatToDo.invoke(obj);
} catch(Exception e) {
println("Exception encountered: " + e);
}
} catch(NoSuchMethodException e) {
println("Exception encountered: " + e);
}
runState = getTimerState();
if (!runState) {
println("timer dead");
this.cancel();
}
}
}
, delay, period);
}
これを手伝ってくれる人に事前に感謝します:)
追加情報:
runStateは、推測できなかった場合に備えてブール値であり、文字はToonクラスのインスタンスです。上記のメソッドはTimerClassクラス内にあり、「timers」はそのクラスのインスタンスです。