rblopes / generator-phaser-plus

[🛑 DISCONTINUED] It has been a long journey but development of `generator-phaser-plus` is now over. I recommend you have a look and fork `yandeu/phaser-project-template` instead.
https://github.com/yandeu/phaser-project-template
MIT License
146 stars 14 forks source link

Facebook Instant Games issue - can't add plugin #35

Open bkirvin opened 5 years ago

bkirvin commented 5 years ago

Node 9.2.1

npm

.yo-rc.json { "generator-phaser-plus": { "meta": { "createdWith": "3.0.0-beta.7", "creationDate": "2019-06-03T18:33:31.708Z" }, "objects": { "dest": "app/scripts/objects/" }, "plugins": { "dest": "app/scripts/plugins/" }, "scenes": { "dest": "app/scripts/scenes/", "index": { "name": "app/scripts/scenes/index.js", "requirePath": "./" } } } }

I have added

to the index.html file head. I also tried adding it to the body above the comment line where scripts are injected.

I also added

new webpack.DefinePlugin({ // Required by Phaser: Enable Canvas and WebGL renderers. 'CANVAS_RENDERER': JSON.stringify(true), 'WEBGL_RENDERER': JSON.stringify(true), 'PLUGIN_FBINSTANT': JSON.stringify(true) }),

to the gulpfile.js/webpack/config/plugins.js file but I get the FBInstant is not defined when I add this to my index.js file

export function boot() { return new Phaser.Game(config); } FBInstant.initializeAsync().then(function() { FBInstant.setLoadingProgress(100); FBInstant.startGameAsync().then(function() { boot(); }); });

Any idea what I'm doing wrong? Other development environments do this and it works great, but this generated development environment is the best I've found yet and I would love to make it my go to project creator.

Thanks for your work on this generator.

rblopes commented 5 years ago

Sorry about that.

It's been a while since I made any significant updates to the generator template, and Facebook Instant Games are a recent addition to Phaser I'm not aware of yet. I'll have a look into this issue later.

bkirvin commented 5 years ago

There are two parts to this plug in. The Facebook SDK referenced by the URL created by Facebook and also Phaser's own plugin phaser-facebook-instant-games.js that exposes calls (this.facebook.call()) within the game code. Thank you for your response.

bkirvin commented 5 years ago

Amazing project generator, btw. I wish Phaser would officially adopt this structure and provide all code examples compliant with this set up.