bryantmakesprog Posted June 18, 2018 Share Posted June 18, 2018 I'm looking to instantiate multiple phaser game objects (three total) in a single view. I'm aware this isn't normally viable, but I was under the impression setting the type to canvas would do the trick. When it runs though, only one instance is generated. Thoughts? InitializeSingleReel(selector, config) { console.log("Configuring Phaser"); var phaser_config = { type: Phaser.CANVAS, width: 64, height: 512, physics: { default: 'arcade', arcade: { gravity: { y: 200 } } }, scene: { preload: PHASER_preload, create: PHASER_create, update: PHASER_update }, parent: selector }; var game = new Phaser.Game(phaser_config); game.ionic = this; return game; } Edit: To elaborate, this function is called three times, each time with a different selector. So it's not the script overwriting a given element (unsure what the behavior would be in that circumstance). Quote Link to comment Share on other sites More sharing options...
rich Posted June 19, 2018 Share Posted June 19, 2018 You can have multiple game instances, even in WebGL: http://labs.phaser.test/view.html?src=src/game config/multiple game instances.js Quote Link to comment Share on other sites More sharing options...
bryantmakesprog Posted June 19, 2018 Author Share Posted June 19, 2018 Hmmm, that doesn't link for me. Is that an example from the Phaser 3 docs? If so I can find it in the rpo. Quote Link to comment Share on other sites More sharing options...
rich Posted June 19, 2018 Share Posted June 19, 2018 My bad, copied it from my local install. Just change phaser.test to phaser.io and it'll work, and yes it's in the examples repo. Quote Link to comment Share on other sites More sharing options...
bryantmakesprog Posted June 19, 2018 Author Share Posted June 19, 2018 Awesome! I'll check it out here shortly Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.