Jump to content

loading bar center horizontally and vertically


espace
 Share

Recommended Posts

Hi,

 I use this snippet to have a loading bar, it works perfect expect for the alignement.

My loading bar is on the left side of my game. how do you center this in the game ?

I put the loading.png in attachement and also the result of the loading bar in my screen

thanks for your help.

 

var boot = function(game){
	console.log("%cStarting my awesome game", "color:white; background:red");
};
  
boot.prototype = {
	preload: function(){
		this.game.load.image("loading","assets/loading.png"); 
	
	},
  	create: function(){
		this.game.scale.pageAlignHorizontally = true;
		this.game.scale.pageAlignVertically = true;
                this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
		this.game.state.start("Preload");
	}
}

 

loading.png

screen.png

Link to comment
Share on other sites

Can you show the code that actually sets that bar as the loading sprite for your game?

Here's code from one of my games that centers the bar in the game screen:

    this.barBg = game.add.sprite(game.world.centerX, game.world.centerY, 'loading-bg');
    this.barBg.anchor.setTo(0.5, 0.5);
    // This bar will get cropped by the setPreloadSprite function as the game loads!
    this.bar = game.add.sprite(game.world.centerX, game.world.centerY, 'loading-fg');
    this.bar.anchor.setTo(0.5, 0.5);
    this.game.load.setPreloadSprite(this.bar);

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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