Sign in to follow this  

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) {

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.