Jump to content

Instantiating Multiple Phaser Games


Recommended Posts

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

Link to comment
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...
 Share

  • Recently Browsing   0 members

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