We're on the home stretch! The last things we have to do are setting up the game timer and showing the level-end screen! Open up PlayState
to make the last few changes.
Since the LevelEndScreen
class is in a package, we'll need to import it to use it, so add this to your import
section:
import source.ui.LevelEndScreen;
Next, we'll have to add new variables to handle the timer functionality:
private var levelTimer:FlxTimer; private var levelTime:Int = 15; private var ticks:Int = 0;
The levelTimer
variable is a FlxTimer
like the one we used when making enemies. The levelTime
variable is the duration that the game will run for. The ticks
variable is used to keep track of the number of seconds that have passed so that we know when to end the game. In other words, it keeps track of how many times the timer has ticked.