Making a game with flixel and Flash Builder 4 – Splash Screen

Did you read Creation of a game with flixel and Flash Builder 4?

Now it’s time to add a splash screen to the game. The splash screen or the title screen is the first thing the player sees, so we’ll add a backround image as well as the game title.

First, we must change our main file, HelloWorld.as, this way:

As you can see, the only change I made can be found at line 9… here I am calling splash_screen class, that is the brand new class we are going to create.

Here it is:

then PlayState class does not change…

And this is the result:

Follow splash screen instructions to “play”… next time, the game itself

  • Dude

    I’m using v2.34

    It worked after I replaced:

    public function splash_screen():void

    with

    override public function create():void

  • Ooo nice. Thanks!

  • I get an error on line 7:
    [Embed(source=”../media/splash.png”)] public var splash_image:Class;

    unable to resolve ‘../media/splash.png’ for transcoding | splash_screen.as | /HelloWorld/src | line 7 | Flex Problem

    any help?
    :D

    • amaca

      just put your png file in the right path ../media/splash.png

  • Mynonas

    using flex 4.5

    had to change line 38 from:

    FlxG.state = new PlayState();

    to:

    FlxG.switchState(new PlayState());

    since FlxG.state changed to read-only.
    works like a charm!

    thanks for the tutorial Emanuele! :)

  • Great tut, i needed to change

    FlxG.fade.start(0xff000000, 1, on_fade_completed);
    to
    FlxG.fade(0xff000000, 1, on_fade_completed);

    thx all for the previous comments they helped.