returnKitten Posted July 8, 2021 Share Posted July 8, 2021 I've been able to successfully initialize a game in my React project using: const game = new Phaser.Game({ type: Phaser.WEBGL, //backgroundColor: 0x000000, pixelArt: false, transparent: true, scale: { mode: Phaser.Scale.FIT, parent: 'engine', autoCenter: Phaser.Scale.CENTER_BOTH, width: 1200, height: 800 }, physics: { default: 'matter', matter: { gravity: { y: -1 }, debug: true } }, scene: { preload: this.preload, create: this.create, update: this.update } }); But I'm having trouble interacting with it from React app. I initialize a websocket connection in useEffect() and want to add a body to my game every time that websocket connection receives data. I've looked into EventEmitter, but the documentation/examples on EventEmitters don't illustrate any case where the events are being sent from 'outside' Phaser. From what I understand, there is a "master" EventEmitter which I get from the game object and another EventEmitter connected to the scene. What's the appropriate way to access the EventEmitter connected to my scene using the game object I receive from `new Phaser.Game()`? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.