Jump to content

To show preloading screen before welcome screen


ozgun
 Share

Recommended Posts

Hello, I've made a pixi project and it's done. I need to show preloading bar graphic before game is started. How can i do this? By the way i am using webpack babel and typescript.

Here is my index.ts:

import { WelcomeScreen } from './screens/WelcomeScreen';
import { ScenesManager } from './ScenesManager';
import { Settings } from './utils/Settings';

import * as PIXI from 'pixi.js';

ScenesManager.create(Settings.ScreenWidth, Settings.ScreenHeight, true);

const loader = PIXI.Loader.shared;
loader.add('gameAtlasTexture', './assets/images/texture.json')
    .add('introAtlasTexture', './assets/images/happyIntroTexture.json')
    .add('letterSound', './assets/sounds/letterSound.mp3')
    .add('bounceSound', './assets/sounds/bounceSound.mp3')
    .add('voiceSound', './assets/sounds/voiceSound.mp3')
    .add('background', './assets/sounds/background.mp3')
    .add('vs2Sound', './assets/sounds/vs2Sound.mp3')
    .add('shakeSound', './assets/sounds/shakeSound.mp3')
    .add('moveSound', './assets/sounds/moveSound.mp3')
    .add('victorySound','./assets/sounds/victory.mp3')
    .add('clickSound','./assets/sounds/click.mp3')
    .add('introLetterTexture', './assets/images/letters.json').load();

loader.onProgress.add((percent) => {
 console.log(percent.progress)
   
   // I NEED TO SHOW PRELOADING BAR PROGRESS IN HERE

 });
loader.onError.add((error) => { console.error(`********* Error! ${error} ${error.file}`) });
loader.onComplete.add(() => {
    bringFirstScene();
});

function bringFirstScene() 
{
    if(mobileCheck())
    {
        Settings.isMobile = true;
    }

    ScenesManager.createScene('welcomeScene', WelcomeScreen);
    ScenesManager.goToScene('welcomeScene');
}

Thank you.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...