new b5.TasksManager(){b5.TasksManager}
core/tasks.js, line 105
A TasksManager manages a collection of Tasks. The App and each Actor / Scene has its own TasksManager
// An example showing how to create a task that starts after 3 seconds and runs 10 times
var app = b5.app;
var task = app.tasks.add("task1", 3, 10, function(task)
{
console.log("Task ran");
console.log(task);
}, this);
// An example showing how to create a task that starts after 3 seconds and runs 10 times every 2 seconds
var app = b5.app;
app.tasks.add("task1", 3, 10, function(task)
{
console.log("Task ran");
console.log(task);
}, this).wait = 2;
Properties:
Name | Type | Description |
---|---|---|
tasks |
Array.<b5.Task> | Array of tasks that are managed by this manager |
Returns:
Type | Description |
---|---|
b5.TasksManager |
|
Methods
-
add(task_name, delay_start, repeats, task_function, task_data){b5.Task}
core/tasks.js, line 120 -
Adds the named task to the manager
Name Type Description task_name
string The name of the task
delay_start
number Amount of time to wait before starting the task
repeats
number Number of times to repeat the task before destroying it, pass -1 to run forever
task_function
function The task function to call
task_data
object Data that is passed to the task function when called
Returns:
Type Description b5.Task The added task -
clear()
core/tasks.js, line 185 -
Removes all tasks from the manager
-
execute()
core/tasks.js, line 193 -
Executes all running tasks within this tasks manager, automatically called by parent app or scene
-
find(task_name){b5.Task}
core/tasks.js, line 168 -
Finds the named task
Name Type Description task_name
string The name of the task
Returns:
Type Description b5.Task The found task or null if not found -
remove(task_name)
core/tasks.js, line 131 -
Removes the named task from the manager
Name Type Description task_name
string The name of the task
-
removeTask(task)
core/tasks.js, line 149 -
Removes the task from the manager
Name Type Description task
string The task to remove