Search code examples
formatgame-developmenthaxehaxeflixelflixel

How to fadeOut splash screen after a couple seconds?


I have the following splash screen:

        final boundingBox = new FlxSprite();

        boundingBox.makeGraphic(300, 200, 0xff428BBF);
        boundingBox.screenCenter(XY);
        add(boundingBox);

        final level_1_text = new FlxText(0, 0, 0, "LEVEL 1", 36);
        level_1_text.screenCenter(XY);
        add(level_1_text);

It's currently in a SubState, and I'm opening it in my Level1 update function. What I want is for the screen to Fade Out after a few seconds, but still have game functionality.

Is it better to just create the splash screen in the Level itself? To just create a function?

I couldn't find any documentation on how to fade out text. How can I fade it out after 5 seocnds?


Solution

  • To fade out the text you can use FlxTween.

    FlxTween.tween(textObject, {alpha: 0}, seconds);

    OR you can use FlxSpriteUtil

    FlxSpriteUtil.fadeOut(textObject, seconds).