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

Phaser plugins integration #74

Closed
Huljo opened this issue Sep 10, 2018 · 1 comment
Closed

Phaser plugins integration #74

Huljo opened this issue Sep 10, 2018 · 1 comment

Comments

@Huljo
Copy link

Huljo commented Sep 10, 2018

Hello,

I try to use some Phaser plugins but nothing works for me.

My first attempt was with Slick-UI.

As suggested here I just added the plugin inside my vendors bundle and added it in my game using the preload function (src/states/Boot.js) but I get an unexpected result :

webpack.config.js :

var slickui = path.join(__dirname, '/node_modules/slick-ui/dist/slick-ui.min.js')
[...]
  entry: {
    app: [...],
    vendor: [..., 'slickui']
  },
module: {
    rules: [...
      { test: /slick-ui\.min\.js/, use: ['expose-loader?SlickUi'] } // SlickUi = {<empty object>} in browser
    ]
  },
  resolve: {
    alias: { ...
      'slickui': slickui
    }
  }

src/index.html :

    <script>
      var SlickUI;
    </script>

src/states/Boot.js :

preload() {
 SlickUI = this.game.plugins.add(Phaser.Plugin.SlickUI);
}

src/states/Boot.js :

create() {
 var panel;
 SlickUI.add(panel = new SlickUI.Element.Panel(8, 8, 150, this.game.height - 16)); // Throw an Error : "Uncaught TypeError: Cannot read property 'Panel' of undefined"
}

In the plugin demo (here) the plugin object looks like this (Plugin added to the game):

> SlickUI
{
  Container: Object
  Element: Object // < The property I want to use
  Keyboard: Object
  namespace: Function
}

But in my case I get a different object (Plugin added to the game):

> SlickUI
{
  active: true,
  defaultRenderer: Object,
  game: Game,
  hasPostRender: true,
  hasPostUpdate: false,
  hasPreUpdate: true,
  hasRender: true,
  hasUpdate: true,
  parent: Phaser.PluginManager,
  renderer: Object,
  visible: true,
  __proto__: Phaser.Plugin
}

Slick-Ui add itselft to Phaser's plugins global object :
Phaser.Plugin.SlickUI // I can reach this one
It need Phaser.Plugin.prototype to properly initiate the plugin (before using it in game)

Any help welcome, Im stuck with this issue since a few days..

@lean
Copy link
Owner

lean commented Sep 13, 2018

Flaxis/slick-ui#26
please check if that library is working as npm module. If is not, you could include in the html (old school mode)

@lean lean closed this as completed Oct 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants