Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spine Plugin Cannot create with multiple game instances. #5765

Closed
xiamidaxia opened this issue Jun 30, 2021 · 5 comments
Closed

Spine Plugin Cannot create with multiple game instances. #5765

xiamidaxia opened this issue Jun 30, 2021 · 5 comments
Labels
🐛 Spine An issue arising from the Spine runtime

Comments

@xiamidaxia
Copy link

xiamidaxia commented Jun 30, 2021

Version

  • Phaser Version: V3.55.2

  • Operating system: Mac

  • Browser: Chrome 91.0.4472.114

Description

I'm developing a game editor that requires just multiple instances of phaser

spine

Example Test Code

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Phaser test</title>
    <script src="http://localhost:8000/build/3.55.2.js"></script>
    <script src="http://localhost:8000/plugins/3.50.x/SpinePluginDebug.js"></script>
</head>
<style>
    canvas {
        display: inline-block;
        margin-right: 20px;
    }
</style>
<body>

</body>
<script>
    const bootScene = {
        preload() {
            this.load.spine('set1', 'http://localhost:8000/assets/spine/3.8/demos/demos.json', [
                'http://localhost:8000/assets/spine/3.8/demos/atlas1.atlas',
                'http://localhost:8000/assets/spine/3.8/demos/atlas2.atlas',
                'http://localhost:8000/assets/spine/3.8/demos/heroes.atlas'
            ], true);
        },
        create() {
            this.add.spine(200, 200, 'set1.alien').setScale(0.5);
        }
    };
    var game1 = new Phaser.Game({
        width: 400,
        height: 400,
        parent: document.body,
        plugins: {
            scene: [
                {
                    key: 'SpinePlugin',
                    plugin: SpinePlugin,
                },
            ]
        },
        scene: [bootScene]
    });
    var game2 = new Phaser.Game({
        width: 400,
        height: 400,
        parent: document.body,
        plugins: {
            scene: [
                {
                    key: 'SpinePlugin',
                    plugin: SpinePlugin,
                },
            ]
        },
        scene: [bootScene]
    });
</script>
</html>

Additional Information

image

@xiamidaxia
Copy link
Author

xiamidaxia commented Jun 30, 2021

image

I fixed the plug-in loading problem, but found a new one.

image

@xiamidaxia
Copy link
Author

Share the global scene renderer make this problem.

image

xiamidaxia pushed a commit to xiamidaxia/phaser that referenced this issue Jun 30, 2021
xiamidaxia pushed a commit to xiamidaxia/phaser that referenced this issue Jun 30, 2021
@phamconganh
Copy link

i hope it will soon merged. I have the same problem

@phamconganh
Copy link

@xiamidaxia I think the PluginCache also need to be edited. Because when you removeScenePlugin, the PluginCache will remove the plugin from any active scene that are already using it

  /**
   * Removes a scene plugin from the Plugin Manager and Plugin Cache.
   *
   * This will not remove the plugin from any active Scenes that are already using it.
   *
   * It is up to you to remove all references to this plugin that you may hold within your game code.
   *
   * @method Phaser.Plugins.PluginManager#removeScenePlugin
   * @since 3.8.0
   *
   * @param {string} key - The key of the plugin to remove.
   */
  removeScenePlugin: function (key) {
    Remove(this.scenePlugins, key);

    PluginCache.remove(key);
  },

@photonstorm photonstorm added the 🐛 Spine An issue arising from the Spine runtime label Jul 20, 2021
@photonstorm
Copy link
Collaborator

Thanks for opening this issue, and for submitting a PR to fix it. We have merged your PR into the master branch and attributed the work to you in the Change Log. If you need to tweak the code for whatever reason please submit a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Spine An issue arising from the Spine runtime
Projects
None yet
Development

No branches or pull requests

3 participants