Ticking Controllers
Controllers can be ticked
Controllers have an onTick method, however they are disabled by default in controllers that do not define that they can be ticked. This is due to very obvious performance reasons.
Ticking a Controller
To tick a controller, you really only need to add 2 things.
- @Ticked(delay) annotation
- onTick() method
package org.phantomapi.example;
import org.phantomapi.construct.Controllable;
import org.phantomapi.construct.Controller;
import org.phantomapi.construct.Ticked;
@Ticked(0)
public class ExampleController extends Controller
{
public ExampleController(Controllable parentController)
{
super(parentController);
}
@Override
public void onStart()
{
}
@Override
public void onStop()
{
}
@Override
public void onTick()
{
}
}
As you can see in the current example, we have defined the ticked annotation as @Ticked(0)
. This tells the phantom provider that this controller needs to be ticked with 0 delay (1 does the same thing as 0). This means that this controller will be ticked 20 times a second. However if you were to define @Ticked(200)
the controller would tick every 10 seconds.