Sign in to follow this  
brentstrandy

Pass custom variable into Phaser.Game()

Recommended Posts

I'm trying to seed my game with custom data. For example, in Phaser 2 I was able to instantiate a new Game object with any number of parameters. It seems Phaser 3 is only looking for a config object with specific properties and nothing more. Is there a way to do this?

new Phaser.Game({
  type: Phaser.AUTO,
  width: 916,
  height: 400,
  scene: [BootScene, PreloaderScene, MenuScene, GameScene],
  antialias: true,
  myCustomObject: { }
});

Note the "myCustomObject" passed into the game.

I would prefer to keep my Phaser implementation to one line and not have to resort to the following:

var myGame = Phaser.Game(config);
myGame.scene.start('myScene', myCustomObject);

 

Share this post


Link to post
Share on other sites

I think it would have to be 

{
  callbacks: {
    preBoot: function (game) {
      game.registry.merge(myCustomObject);
    }
  }
}

You could make a feature request. Maybe a game config key like data that could pass through arbitrary data.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.