O'Reilly logo

Haxe Game Development Essentials by Jeremy McCurdy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required