Jump to content

Use states but pass another phaser setup parameter


Recommended Posts



I'm using states but I need to pass in another parameter to the default new phaser.game arguments, let me show you what I mean; 


var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: eurecaClientSetup, update: update, render: render });

You see that example uses the "EurecaClientSetup" in the create how can I pass that argument when the code is formatted using states?


For example I would need - 

gameName.Game.prototype = {    create: function EurecaClientSetup() {    }}
Link to comment
Share on other sites

That last bit of code doesn't make (syntactical) sense

create: is just the name of a function , so either

.., create: create

in your constructor, then

create: function() {   eurecaClientSetup()

Or (less preferably)

.., create: eurecaClientSetup,


eurecaClientSetup: function() {
Link to comment
Share on other sites

I think you mean this?

gameName.Game.prototype.create = EurecaClientSetup;

And, just to be nitpicky know-it-all, this syntax:

var o = {  create: function catpants() {  }}

DOES make syntactic sense, but it doesn't assign the function "catpants" defined elsewhere to the property "create" of the object "o". It just names the function assigned to "o.create" as "catpants" which will make your stacktraces much nicer.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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