Intervals are very similar to tasks in that they are used to perform an action over time.
Note
They are also similar to animations because they can be controlled with simple start, loop, and stop methods just like animations.
Unlike tasks, Intervals automatically take into account the passage of time instead of executing on each frame, or waiting an amount of time to then execute in a single frame. They also use a finite duration of time, and stop automatically when that amount of time has passed.
To use Intervals, we need to import them with this import line:
from direct.interval.IntervalGlobal import *
Then, we can create Intervals by calling the constructor and giving it the necessary arguments:
myInterval = Constructor(arguments)
The actual constructor varies from Interval
type to Interval
type.
Exactly what an Interval
does depend on the type of Interval
in question. Here's a list of types of Intervals: