Sign in to follow this  
Followers 0
Sir Vasile

Problem with z-index when creating a loader

2 posts in this topic

Hello, I created a LoadingBar class which contains a loading bar and a background.

I load the resources of the LoadingBar in my Boot state and the loader works.

The problem is that my LoadingBar has a background that has width 100% of the game width. And height 100% of the game height. When the resources of my state are loaded the create method is called. When the create method is called all the created sprites overlap the background of my LoadingBar.

I don't want to destroy my LoadingBar when the resources are loaded but only when the "create" method has finished, because it creates the maps/buildings/sprites/characters/enemies... and other things.

So I want to destroy/hide my Loading screen only when all sprites are created (only when the create method has finished to create the world). But when they are created they immediately overlap my background.

So the question is: what can I do to the background of the LoadingBar to make it be always the highest z-index?

 

class World extends Phaser.State {
    preload () {
        this.loadingBar = new LoadingBar();
        // load sprite sheets.. music.. ..
    }

    create ()
    {
        buildMap(); // Houses overlap the background of the loading screen
        buildJoypad(); // Joypad buttons overlap the background of the loading screen
        build...
        build.....
        // done
        this.loadingBar.destroy();
    }
}

 

Share this post


Link to post
Share on other sites

Arrange like this:

- Stage
  - World
    - Sprites
    - …
  - LoadingBarGroup
    - Background
    - Bar

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.