Sign in to follow this  
mcofko

Including ParticleStorm into TS Project

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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.