Jump to content

Including ParticleStorm into TS Project


mcofko
 Share

Recommended Posts

Hi guys,
 
I'm trying to add Phaser particle system plugin to  my starter project. I've bought the ParticleStorm yesterday and thought it would be practically self explanatory to add it to the project. But it was not that way :)
 
I really hope you have any idea or could give me any tips, how can I come closer to the solution. It seems that I really lack knowledge about Webpack + Npm/node modules :) 
 
Let's start at the beginning. I bought the system, and got a package which seems like a module, so I've copied the complete project folder inside my node_modules folder. I've tried to manually install the package npm install -g phaser-particle-storm or npm install -g ./phaser-particle-storm, but I get "Could not install from "phaser-particle-storm" as it does not contain a package.json file. (ERR ENOLOCAL)". I moved further, thinking maybe I do not need to install it, so I've added path to particlestorm.d.ts into tsconfig.json. And then I've tried to add the module to Phaser.Game.PluginsManager like this: this.manager = this.game.plugins.add(Phaser.ParticleStorm);.
And because phaser.d.ts has this line of the code at the beginning of the file declare module "phaser-ce" { export = Phaser; }, I think that it wants to look after the ParticleStorm inside phaser-ce.js or even phaser-split.js (do you know maybe whats with that split variant? ). 
My next try was then to add something similar to the particlestorm.d.ts, like declare module "phaser-particle-storm" { export = Phaser.ParticleStorm; }, and then in my class I have an import statement import * as PStorm from 'phaser-particle-storm';, but then I get a complain, that it can not find the module.
 
Adding particlesstorm.js and particlestorm.d.ts scripts inside my project did not result in any success.
 
I would like that the plugin would be part of the project like Phaser game engine is. I have no clue in which direction do I need to go from here. Obviously I'm missing something.
Link to comment
Share on other sites

Solution to my problem was to create an alias in webpack.config.js file:

resolve: {
        alias: {
            particlestorm: path.join(root, 'lib/phaser-gogame-shared/src/plugin/particle-storm.js')
        }
}

And then I fixed my import statement to: import 'particlestorm' and that's it.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...