Quote:
Originally Posted by notmattlythgoe
Code:
public class ShootCommand extends Command {
public void initialize() {
logic for fire1;
}
public void execute() {
}
public boolean isFinished() {
return timeSinceInitialized() > 1;
}
public void end() {
logic for fire 2;
}
}
1. Run fire1 logic when command starts.
2. Do nothing for 1 second.
3. After 1 second return true in isFinished().
4. When isFinished() returns true the end() method is called.
5. Run logic for fire2 in end.
|
OK thanks that's pretty clear. Is there any performance difference between the approach shown above and the code in post#15? Which approach do you prefer, and why (or does it depend on context)?