Implementing the game timer
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.
Importing the end screen
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;
Adding variables
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 ...
Get Haxe Game Development Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.