Repository navigation
Tasks
ZSolarDev edited this page Nov 10, 2026
·
2 revisions
The task system is simple to use. To create a task, you can make a class extending diva.DTask:
import diva.task.DTask;
class DummyTask extends DTask {
// Constructor.
public function new() {}
// Called when this task is registered.
override public function init() {
super.init();
// Code here.
}
// Called when this task is updated.
override public function update() {
super.update();
// Code here.
}
// Called when this task is destroyed.
override public function destroy() {
// Code here.
super.destroy();
}
// Called when this task is able to draw.
override public function draw() {
super.draw();
// Code here.
}
}There's also a function in DTask called basic(). This is left undocumented, because I don't know what it's for. If someone could let me know, that would be great.
Once you create your task, you can register and unregister it under a name as such:
Diva.taskManager.registerTask('DummyTask', new DummyTask());
Diva.taskManager.unregisterTask('DummyTask', destroy);The destroy parameter under unregisterTask is if the task should have destroy() called on it or not.