SplashScreen best way

Anything libgdx related goes here!

SplashScreen best way

Postby TruePlayer » Thu Sep 12, 2019 2:07 pm

tell me the best way to create SplashScreen, I tried to make a simple Screen with a logo, but still get a delay and a black screen, I would like to get an image right away when I click on the icon as it was done in many games (for example, Alto)
TruePlayer
 
Posts: 103
Joined: Sun Jul 28, 2019 12:22 pm

Re: SplashScreen best way

Postby evilentity » Thu Sep 12, 2019 2:42 pm

You make a screen with a splash in it.
You probably get delay cus you still load everything first before showing the screen.
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4851
Joined: Wed Aug 24, 2011 11:37 am

Re: SplashScreen best way

Postby TruePlayer » Thu Sep 12, 2019 4:31 pm

I will check your statement, make an AssetManager load class and compare the results and write here
TruePlayer
 
Posts: 103
Joined: Sun Jul 28, 2019 12:22 pm

Re: SplashScreen best way

Postby yobowargames » Thu Sep 12, 2019 7:37 pm

Quick example below. You need to make sure AssetManager has finished loading your splashscreen first before you load anything else in.

assetManager = new AssetManager();

// Load splash screen and music
assetManager.load("sounds/soundtrack.mp3", Sound.class);
assetManager.finishLoading();
sound = assetManager.get("sounds/soundtrack.mp3");
sound.play();
assetManager.load("menus/splashscreen.txt", TextureAtlas.class);
assetManager.finishLoading();
// Then assign splashscreen to be displayed etc...
yobowargames
 
Posts: 11
Joined: Sat Oct 27, 2018 4:25 pm

Re: SplashScreen best way

Postby TruePlayer » Fri Sep 13, 2019 2:51 pm

Code: Select all
public class LoadingView implements Screen {

    private Main app;
    private ShapeRenderer shapeRenderer;
    private float progress;
    private BitmapFont font;
    private GlyphLayout glyphLayout;


    public LoadingView(Main app){
        this.app = app;
        this.shapeRenderer = new ShapeRenderer();
        this.progress = 0f;
        this.font = new BitmapFont();
        this.font.setColor(Color.WHITE);
        this.glyphLayout = new GlyphLayout();
        loadAssets();
    }


    private void update(float delta){
        //a + (b-a) * lerp
        progress = MathUtils.lerp(progress, app.assetManager.getProgress(), .1f);
        if (app.assetManager.update() && progress >= app.assetManager.getProgress() - .001f){
            app.setScreen(new MenuView(app.getGsm()));
        }
    }

    private void loadAssets() {
        app.assetManager.load("textures/back.png", Texture.class);
        app.assetManager.load("textures/field.png", Texture.class);
        app.assetManager.load("logo.png", Texture.class);
        app.assetManager.load("skin/skin/uiskin.json", Skin.class);
    }

    @Override
    public void show() {
        glyphLayout.setText(font, "LOADING...");
    }

    @Override
    public void render(float delta) {
        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        update(delta);

        app.getSpriteBatch().begin();
        font.draw(app.getSpriteBatch(), glyphLayout,app.getWeight()/2 - glyphLayout.width/2, 80);
        app.getSpriteBatch().end();

        shapeRenderer.setProjectionMatrix(app.getCamera().combined);
        shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
        shapeRenderer.setColor(Color.WHITE);
        shapeRenderer.rect(50, 50,220, 16);
        shapeRenderer.setColor(Color.BLACK);
        shapeRenderer.rect(55, 55,progress * (210), 6);
        shapeRenderer.end();
    }

    @Override
    public void resize(int width, int height) {

    }
    @Override
    public void pause() {

    }
    @Override
    public void resume() {

    }
    @Override
    public void hide() {

    }
    @Override
    public void dispose() {

    }
}


This is my loading screen, lightweight and fast. But even starting it first, I get some downtime. I’m starting to think that it’s not about loading assets (I don’t have much of them, even music). Probably need to add something to the layout in android? who thinks what?
try running the game "Alto" again.
This is not an advertisement. In this game you don’t even see animations disappearing navigation buttons, immediately by clicking on the icon you get a loading screen.
TruePlayer
 
Posts: 103
Joined: Sun Jul 28, 2019 12:22 pm

Re: SplashScreen best way

Postby evilentity » Fri Sep 13, 2019 3:58 pm

new BitmapFont() will block on loading the font. It should be plenty fast anyway.

Define 'some downtime'. It takes less then a second for initial screen to show up on low end device for game im working on. On modern device its pretty much instant.
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4851
Joined: Wed Aug 24, 2011 11:37 am

Re: SplashScreen best way

Postby TruePlayer » Fri Sep 13, 2019 5:59 pm

evilentity wrote:new BitmapFont() will block on loading the font. It should be plenty fast anyway.

Define 'some downtime'. It takes less then a second for initial screen to show up on low end device for game im working on. On modern device its pretty much instant.


new BitmapFont() - does not block, and I'm glad about it)
I agree that the first events on the screen appear very quickly.
but in some games this happens even faster! I repeat in some games we do not see the animation of the disappearance of the android navigation buttons!

I understand that my English is too bad to explain my thoughts. I recorded a video from the screen of my Xperia xa1 phone, this is a fairly modern phone,
I first start my project , and then the game Alto:
https://youtu.be/VYzle-tuGI8

perhaps it seemed to me that Alto starts faster?)
TruePlayer
 
Posts: 103
Joined: Sun Jul 28, 2019 12:22 pm

Re: SplashScreen best way

Postby evilentity » Fri Sep 13, 2019 9:10 pm

Both of these look slow to me. On my old nexus 4 it shows up faster.
Try new, empty project and see how fast it shows up. Hard to do less then that.

new BitmapFont() loads the font from two files, that by definition blocks. Still, the files are small and it should be quite fast.
Looking for a freelancer? PM me!
Check out libgdx discord server!
evilentity
 
Posts: 4851
Joined: Wed Aug 24, 2011 11:37 am


Return to Libgdx

Who is online

Users browsing this forum: Bing [Bot], BobIsHere, Google [Bot] and 1 guest