How do I take an existing Phaser game and make it multiplayer?
Can I use the Lance library for this purpose? Both libraries control their own game objects so I don't know how to use the two frameworks together in the same game.
Disclaimer: I am one of the co-creators of Lance
Unfortunately, Phaser's 2.* architecture makes it hard to pair with Lance to make Realtime Javascript Multiplayer games.
The issue is that Phaser makes a lot of assumptions that don't hold for a multiplayer setting. For example, the rendering and game loop are tied together. The server, obviously doesn't need to render anything.
Phaser also assumes the existence of the DOM and the window
object which also don't exist on the server. In addition, all of the data structures that hold the world game state objects, sprites, etc' are saved on an extended instances PIXI objects which don't make sense in a Server context. These limitations and tight-coupling aren't compatible with Lance's modular approach.
It is entirely possible to run Phaser on the server using libraries that emulate DOM and Canvas like JSDOM and Node Canvas however it does mean that there's a significant performance degradation by running PIXI on the server, and you also still have the problem of syncing PIXI data structures to contend with.
The good news is that Phaser 3.0 is an ongoing, complete rewrite of Phaser 2.0 in a much more modular approach will hopefully make it much easier to integrate with Lance. We have plans to make this integration easier ourselves in the near future.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With