Quote:
Originally Posted by Ether
Within the command-based architecture, what is the recommended way to implement a delay (for example, in a firing sequence).
|
I would suggest using a WaitCommand in a CommandGroup. Below is an example that will fire, then wait 1 second before firing again and then finishing the CommandGroup.
Code:
public FiringCommandGroup extends CommandGroup {
public FiringCommandGroup() {
addSequential(new FireCommand());
addSeqiential(new waitCommand(1));
addSequential(new FireCommand());
}
}
Another way to do it would be to check the time passed in the execute method of a command to see if the period of time you want to wait has passed.
Commands also have a timeSinceInitialixed() method that will return the time in seconds since the command was initialized(aka started). This could be used to check to see if a command has been running for a certain period of time.