Can I make a multiplayer Phaser game using Lance?

最后都变了- 提交于 2019-12-22 09:08:03

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/44085045/can-i-make-a-multiplayer-phaser-game-using-lance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!