Jump to content

Pass custom variable into Phaser.Game()


brentstrandy
 Share

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

 

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 year later...

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...
 Share

  • Recently Browsing   0 members

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