Question

When the user presses a play button I want a simple "Loading..." text to be attached to the MenuScene. This is my code:

attachChild(new Text(400, 150, resourcesManager.font,
                        "Loading...", vbom));
                SceneManager.getInstance().loadGameScene(engine);

It doesn't work because of the second statement in which I load the GameScene. The text works, but for some reason is not shown if the game is loaded right after. Workarounds?

Was it helpful?

Solution

use Entity modifier like this:

        IEntityModifierListener listener = new IEntityModifierListener() {
        GameScene  gScene = null;
        @Override
        public void onModifierStarted(IModifier<IEntity> pModifier, IEntity pItem) {
            attachChild(new Text(400, 150, resourcesManager.font, "Loading...", vbom));
            // load resources here
            gScene = new GameScene();
            gScene.LoadResources();

        }                                                                                                             
        @Override
        public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
            // set Scene  here
            gScene.loadScene();

        }
    };
    playButton.registerEntityModifier(new DelayModifier(4, listener));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top