Closed richardhealy closed 7 years ago
Shim happens here:
https://github.com/richardhealy/emagine/blob/master/helpers/shims/Phaser.js
As we discussed in the Phaser Slack, this is down to the plugin not being built for ES6. Seeing as you're only exporting Phaser there, the code will run but SAT will not be available globally (not everything is kept under one namespace).
This isn't something I'm looking to improve until an ES6 version of Phaser (Lazer) is released.
I ran into this problem as well but I've found a way to solve it. Following the webpack config pattern of the Phaser ES6 Webpack boilerplate, you could add this to the your webpack config file as a rule under module.rules
.
{
test: /phaser-arcade-slopes\.js$/,
use: [{
loader: 'expose-loader',
options: 'SAT'
}]
}
This exposes the SAT as a global variable using the expose-loader.
Make sure to import and register the Arcade Slopes plugin in your level file like so:
import ArcadeSlopes from 'phaser-arcade-slopes'
// in the create function
create () {
this.game.plugins.add(Phaser.Plugin.ArcadeSlopes)
}
Now you can use the plugin with a ES6 Webpack setup!
Nice! This will suffice until #41 is satisfied. :)
I've tried to shim phaser-arcade-slopes in my game. I keep getting a:
SAT is not defined
A more full description is found here: http://www.richardhealy.co.uk/blog/phaser-issue-help
And code is found at:
https://github.com/richardhealy/emagine