Using MVC with libgdx scene2d [closed]

。_饼干妹妹 提交于 2019-12-01 08:33:49

This is a mostly opinion-based question, but it is one that comes up very often when it comes to scene2d and the MVC pattern.

In general it always makes sense to seperate concerns like the Model-View-Controller pattern tries to do. With scene2d this is not that easy, because Actors have already an act() and a draw() method.

In my opinion you should always try to model your game world (entities) like they are. There should be a Player, maybe a Rocket and maybe a Bunny class/actor/entity and they should know everything they need to know and manage themselves. This is the opposite of an Entity-System-Framework where your entities are made of "parts" and those are controlled by external systems.

Most of the time keeping everything together makes it also more flexible, because you already have everything you need in one place. Your gameplay might change and so will your entities. If you find that your entities get too big, you can still split those up in several parts like a PlayerModel, PlayerController and a PlayerRenderer which need references to each other and then trigger those in your act() and render() methods.

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