When a task is added to the task manager, it may be given an optional priority. We've actually seen these priorities already; remember the sort column of the print(taskMgr)
output? That column shows the priorities assigned to the tasks in the task manager. Tasks with a lower priority are executed before tasks with a higher priority. That may seem a little backwards, but that's the way it is.
The default priority of a new task is 0
. To assign a different priority, just add a priority number to the end of the add
or doMethodLater
call.
taskMgr.add(self.myTask, "My Task Name", 5) taskMgr.doMethodLater(10, self.myTask, "My Task Name", 129)
Tasks with the same priority number are executed in no particular order, and that order may change from frame to frame. However, if two tasks have priority 1 and two tasks have priority 5, both of the tasks with priority 1 will execute before either task with priority 5.
Prioritizing tasks this way can be helpful, but generally it isn't needed...