Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Using the Game.prototype


Monstamash
 Share

Recommended Posts

Hi All

 

Very sorry for asking another noobish question. I have just about finished my first Phaser game (yay!) The final thing I was implementing was preloader, and started following the example in resources/project template/basic

 

From what I understand, I need to put my game into a prototype which means changing things like

 

function myFunction()  -> myFunction: function()

game.add.button(...); -> this.add.button(...);

var myVar; -> this.myVar

myFunction(); -> this.myFunction();

t.onComplete.add(anotherFunc, this); -> t.onComplete.add(this.anotherFunc, this);

 

and so on. It seems like a massive amount of chages to make, and I am getting error after error which I didnt get when I had finished my game written in the more conventional way shown in all the examples.

 

My question is, is there a way to have a preloader, without having to put my game into a prototype?

 

Thanks for any advise in advance!

Link to comment
Share on other sites

Yes for sure. Stick this in your preload function:

game.load.onFileComplete.add(updateProgressBar, this);

and then this function:

function updateProgressBar(progress) {// progress is a value between 0 and 100 which can be used to// easily make a progress bar, i.e. modify the Sprite width/crop between 0 and 100.}
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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