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

[BUG] Cannot pass arguments to my own plugin by using of game.add.plugin() API. #486

Closed
zk-luke opened this issue Mar 1, 2018 · 1 comment
Labels
Milestone

Comments

@zk-luke
Copy link

zk-luke commented Mar 1, 2018

  • A bug in the API: game.add.plugin();
    • Phaser version(s): Phaser CE v2.10.1
    • What should happen: we could pass args to my own plugin.
    • What happens instead: we cannot pass args to my own plugin.

Code In My Game Logic(this will invoke GameObjectFactory.plugin)

game.add.plugin(PhaserSpine.SpinePlugin, CustomConfig);

Code In GameObjectFactory(this will invoke PluginManager.add)

plugin: function (plugin) {
    return this.game.plugins.add(plugin);
}

We miss the CustomConfig at GameObjectFactory.plugin API.

Code In PluginManager

add: function (plugin) {
  //can not get args,we missed it at GameObjectFactory.plugin
  var args = Array.prototype.slice.call(arguments, 1);
   if (typeof plugin['init'] === 'function')
   {
      plugin.init.apply(plugin, args);
   }
}

I think GameObjectFactory.plugin API should like this

plugin: function (plugin, options) {
    return this.game.plugins.add(plugin, options);
}
@samme
Copy link
Collaborator

samme commented Mar 1, 2018

For now you can use game.plugins.add instead:

game.plugins.add(PhaserSpine.SpinePlugin, CustomConfig);

I will work.

@samme samme added the bug label Mar 1, 2018
@samme samme added this to the 2.10.2 milestone Mar 1, 2018
@samme samme closed this as completed in be35d19 Mar 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants