[SOLVED] How do I code a Logo opening & title Screen

Okay, I’m not sure without checking the html and css in the console of the browser. Below is the code that I use in one of my games. I see I use also things that are not used in the original code.

            '#application-splash-wrapper {',
            '    position: absolute;',
            '    top: 0;',
            '    left: 0;',
            '    height: 100%;',
            '    width: 100%;',
            '    background-color: #000000;',
            '}',

            '#application-splash {',
            '    position: absolute;',
            '    top: calc(50% - 28px);',
            '    width: 264px;',
            '    left: calc(50% - 132px);',
            '}',

            '#application-splash img {',
            '    width: 100%;',
            '}',

ok i notice that to not change this part of the code
β€˜#application-splash-wrapper {’,
’ position: absolute;’,
’ top: 0;’,
’ left: 0;’,
’ height: 100%;’,
’ width: 100%;’,
’ background-color: #283538;’,
β€˜}’,
β€˜β€™,

Instead i simply have to change this part

β€˜#application-splash {’,
’ position: absolute;’,
’ top: calc(50% - 28px);’,
’ width: 498px;’,
’ left: calc(50% - 132px);’,
β€˜}’,
β€˜β€™,

i dont know about this part of the code though

β€˜#application-splash img {’,
’ width: 100%;’,
β€˜}’,

ok when i change the number of width: 100%;’, it zooms into the loading screen

I’ve almost figured this out just a few more sec

You can disable the line below to prevent the loading screen dissapears.

app.on('start', hideSplash);

ok

Is this what you want?

https://launch.playcanvas.com/1271818?debug=true

0_0

Yes.

pc.script.createLoadingScreen(function (app) {
    var showSplash = function () {
        // splash wrapper
        var wrapper = document.createElement('div');
        wrapper.id = 'application-splash-wrapper';
        document.body.appendChild(wrapper);

        // splash
        var splash = document.createElement('div');
        splash.id = 'application-splash';
        wrapper.appendChild(splash);
        splash.style.display = 'none';

        var logo = document.createElement('img');
        logo.src = 'https://c.tenor.com/6CMAvyCJpIsAAAAC/sonic06-loading.gif';
        splash.appendChild(logo);
        logo.onload = function () {
            splash.style.display = 'block';
        };

        var container = document.createElement('div');
        container.id = 'progress-bar-container';
        splash.appendChild(container);

        var bar = document.createElement('div');
        bar.id = 'progress-bar';
        container.appendChild(bar);

    };

    var hideSplash = function () {
        var splash = document.getElementById('application-splash-wrapper');
        splash.parentElement.removeChild(splash);
    };

    var setProgress = function (value) {
        var bar = document.getElementById('progress-bar');
        if(bar) {
            value = Math.min(1, Math.max(0, value));
            bar.style.width = value * 100 + '%';
        }
    };

    var createCss = function () {
        var css = [
            'body {',
            '    background-color: #000000;',
            '}',
            '',
            '#application-splash-wrapper {',
            '    position: absolute;',
            '    bottom: 0;',
            '    left: 0;',
            '    height: 100%;',
            '    width: 100%;',
            '    background-color: #000000;',
            '}',
            '',
            '#application-splash {',
            '    position: absolute;',
            '    bottom: 0;',
            '    left: 0;',
            '    width: 100%;',
            '}',
            '',
            '#application-splash img {',
            '    width: 100%;',
            '}',
            '',
            '#progress-bar-container {',
            '    display: none;',
            '}',
            '',
            '#progress-bar {',
            '    display: none;',
            '}',
            '',
            '}'
        ].join('\n');

        var style = document.createElement('style');
        style.type = 'text/css';
        if (style.styleSheet) {
            style.styleSheet.cssText = css;
        } else {
            style.appendChild(document.createTextNode(css));
        }

        document.head.appendChild(style);
    };

    createCss();
    showSplash();

    app.on('preload:end', function () {
        app.off('preload:progress');
    });
    app.on('preload:progress', setProgress);
    app.on('start', hideSplash);
});

30 years later working 24/7 non stop

1 Like