Jump to content

Background Image on stage load


Softmixt
 Share

Recommended Posts

Hi ,  I start a few weeks ago with Phaser and I have some problems that I couldn't find a solution yet so what I actually want to do is this:

I want where a "load bar" is loaded to se a background image instead of solid color  so my  code is : 

/*


BOOT SIDE 


*/
var boot = function ( game )
{
	
};

boot.prototype = {
	
	init : function ()
	{	
	} ,
	preload : function ()
	{
		
		this.game.stage.backgroundColor = "#6cb2f3";
	
		this.game.load.image ( 'loader' , 'sprites/images/loader.png' );
	
	} ,
	create : function ()
	{
		
		//  Set background for our game
		this.game.state.start ( "Preload" );
	}
};

/*


PRELOAD SIDE



*/

var preload = function ( game )
{
};

preload.prototype = {
	preload : function ()
	{

        // the other assets ...
	    this.game.load.image ( 'background' , 'sprites/images/background.png' );
		
        this.preloadBar = this.add.sprite( 150, 550, 'loader');
		this.load.setPreloadSprite(this.preloadBar);
		
	} ,
	create : function ()
	{

		console.log ( "Load the preloader .." );
		
		this.game.state.start ( "GameStart" );

	}
};

The loader image is working same as background color but instead of a background color i want to load an a image .

thanks . 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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