我明白使用"这个"根据您当前所在的范围返回不同的对象。如何将引用返回给我的类,而不是返回此特定方案中的函数?
public void create() {
// Creates 10 second clock and timer that warps the teams to their respective maps to begin.
map_factory.getMap(waiting_map).broadcastMessage(MaplePacketCreator.getClock(10));
// Warps players to respective maps to begin the PQ.
// Starts the scheduler to start spawning initial mobs.
// Sets a timer for 10 minutes; after 10 minutes the end function will execute and end the game.
this.schedule = TimerManager.getInstance().schedule(new Runnable() {
public void run() {
blue_party.warpParty(blue_map);
red_party.warpParty(red_map);
start_time = System.currentTimeMillis();
execute();
startTimer();
}
}, 10000);
}
这个功能在我班上。我尝试将 start_time 设置为当前时间(以毫秒为单位),但这只是创建了一个局部变量。 start_time 实际上是一个类变量。我不确定用什么样的语法来查找这样的问题,所以我觉得问起来会更容易。也许一个更可测试的例子就是:
public void foo() {
this.schedule = TimerManager.getInstance().schedule(new Runnable() {
public void run() {
start_time = System.currentTimeMillis();
}
}, 10000);
}