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

Is it possible to include plugins? #30

Closed
amenant opened this issue Aug 3, 2017 · 4 comments
Closed

Is it possible to include plugins? #30

amenant opened this issue Aug 3, 2017 · 4 comments

Comments

@amenant
Copy link

amenant commented Aug 3, 2017

Hello,
I'd like to add a plugin (https://github.com/lewster32/phaser-plugin-isometric) but can't make it work.
I'm not sure about how to do with the starter project. Any example?

Thanks.

@rroylance
Copy link
Owner

Hi, you should be able to just throw the js file into your assets folder and the game will automatically load it and the plugin will be available. You can then load and activate the plugin in your state's preload function, for example, using: this.game.plugins.add(new Phaser.Plugin.Isometric(this.game));

I haven't tried this exact plugin, but I can try it out this evening if you still can't get it going.

@amenant
Copy link
Author

amenant commented Aug 4, 2017

Hi,
that's what I did but I get an error.

assets.ts (generated)

export namespace Scripts {
    export class ScriptPhaserPluginIsometricMin {
        static getName(): string { return 'phaser-plugin-isometric-min'; }

        static getJS(): string { return require('assets/script/phaser-plugin-isometric-min.js'); }
    }
}
preload(): void {
    this.game.plugins.add(new Phaser.Plugin.Isometric(this.game));
}

[ts] Property 'Isometric' does not exist on type 'typeof Plugin'.

Do I need to make an import? The plugin also provide a .ts file, do I have to make use of it?

Thanks.

@rroylance
Copy link
Owner

Oh, right, I never thought of needing the definitions for typescript when loading certain scripts... Oops.

Yes, you'll need to include the d.ts file in your project (I usually have a folder called definitions in the root (not assets)), and then in the tsconfig.json you need to add the path to the d.ts file to the files array.

That should tell typescript that the library exists and you should be good to go.

Thanks so much for bringing this to my attention, now I can add an additional tutorial or sorts to the readme :)

@amenant
Copy link
Author

amenant commented Aug 4, 2017

Thanks 👍

@amenant amenant closed this as completed Aug 4, 2017
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