Flixel Game Over Screen

Posted by Jamie Read on Game Development See other posts from Game Development or by Jamie Read
Published on 2013-11-09T10:41:46Z Indexed on 2013/11/09 16:16 UTC
Read the original article Hit count: 434

Filed under:
|
|

I am new to game development but familiar with programming languages. I have started using Flixel and have a working Breakout game with score and lives.

I am just stuck on how I can create a new screen/game over screen if a player runs out of lives. I would like the process to be like following:

  1. Check IF lives are equal to 0
  2. Pause the game and display a new screen (probably transparent) that says 'Game Over'
  3. When a user clicks or hits ENTER restart the level

Here is the function I currently have to update the lives:

private function loseLive(_ball:FlxObject, _bottomWall:FlxObject):void
{
    // check for game over
    if (lives_count == 0)
    {

    }
    else 
    {
        FlxG:lives_count -= 1;
        lives.text = 'Lives: ' + lives_count.toString()
    }
}

Here is my main game.as:

package
{
    import org.flixel.*;

    public class Game extends FlxGame
    {
        private const resolution:FlxPoint = new FlxPoint(640, 480);
        private const zoom:uint = 2;
        private const fps:uint = 60;

        public function Game()
        {
            super(resolution.x / zoom, resolution.y / zoom, PlayState, zoom);
            FlxG.flashFramerate = fps;
        }
    }
}

© Game Development or respective owner

Related posts about screen

Related posts about ui-design