A Phaser 3 plugin to generate line segments resembling lightning.
This is a work in progress and is currently in beta.
Run npm install and then npm run build to build the plugin locally.
Use npm run examples to run the exampes locally, then visit localhost:2344 in your browser.
You can load plugins externally, or include them in your bundle.
To load an external plugin:
function preload ()
{
this.load.scenePlugin('LightningPlugin', 'path/to/LightningPlugin.js', 'lightningPlugin', 'lightning');
}Then to install it into a Scene:
this.sys.install('LightningPlugin');If you load the plugins in a Preloader scene then you can add them to any other Scenes by specifying them in the plugins array:
var config = {
scene: {
create: create,
plugins: [ 'LightningPlugin' ],
map: {
'lightning': 'lightning'
}
}
};See inline JSDocs, and the included examples for usage.
The plugin is written in ES2015/ES6, but the built version targets ES5.
This plugin is an implementation of this algorithm, and is based on the Phaser 3 Plugin template by Richard Davey