One thing I absolutely loved during the time I used Phaser for HTML5 game development is the way you did countdowns and timers.
If we could do timers and countdowns like this, it would be insanely useful
new Countdown(5f, () => {
Destroy(gameObject); // run this code after 5 seconds
});
I love this method of doing things because the code that runs after the countdown is grouped together with its declaration. Super clean and useful. And, it makes it really easy to do things like this
new Countdown(0.5f, () => {
Debug.Log("foo");
new Countdown(0.5f, () => {
Debug.Log("bar!");
}
});
Prints foo after half a second, then bar after another half a second.
Of course, you should still be able to keep these countdown objects and cancel them at any time, or restart, etc. We're just changing the way you declare the code you wish to run on completion or progress.
One thing I absolutely loved during the time I used Phaser for HTML5 game development is the way you did countdowns and timers.
If we could do timers and countdowns like this, it would be insanely useful
I love this method of doing things because the code that runs after the countdown is grouped together with its declaration. Super clean and useful. And, it makes it really easy to do things like this
Prints
foo
after half a second, thenbar
after another half a second.Of course, you should still be able to keep these countdown objects and cancel them at any time, or restart, etc. We're just changing the way you declare the code you wish to run on completion or progress.