• <bdo id='KrmxC'></bdo><ul id='KrmxC'></ul>

    <small id='KrmxC'></small><noframes id='KrmxC'>

    <i id='KrmxC'><tr id='KrmxC'><dt id='KrmxC'><q id='KrmxC'><span id='KrmxC'><b id='KrmxC'><form id='KrmxC'><ins id='KrmxC'></ins><ul id='KrmxC'></ul><sub id='KrmxC'></sub></form><legend id='KrmxC'></legend><bdo id='KrmxC'><pre id='KrmxC'><center id='KrmxC'></center></pre></bdo></b><th id='KrmxC'></th></span></q></dt></tr></i><div id='KrmxC'><tfoot id='KrmxC'></tfoot><dl id='KrmxC'><fieldset id='KrmxC'></fieldset></dl></div>

  • <tfoot id='KrmxC'></tfoot>

      1. <legend id='KrmxC'><style id='KrmxC'><dir id='KrmxC'><q id='KrmxC'></q></dir></style></legend>

        将 MVC 与 libgdx scene2d 一起使用

        时间:2023-05-20
            <legend id='KGt5z'><style id='KGt5z'><dir id='KGt5z'><q id='KGt5z'></q></dir></style></legend>
              <tbody id='KGt5z'></tbody>
            <tfoot id='KGt5z'></tfoot>

            <i id='KGt5z'><tr id='KGt5z'><dt id='KGt5z'><q id='KGt5z'><span id='KGt5z'><b id='KGt5z'><form id='KGt5z'><ins id='KGt5z'></ins><ul id='KGt5z'></ul><sub id='KGt5z'></sub></form><legend id='KGt5z'></legend><bdo id='KGt5z'><pre id='KGt5z'><center id='KGt5z'></center></pre></bdo></b><th id='KGt5z'></th></span></q></dt></tr></i><div id='KGt5z'><tfoot id='KGt5z'></tfoot><dl id='KGt5z'><fieldset id='KGt5z'></fieldset></dl></div>

                <small id='KGt5z'></small><noframes id='KGt5z'>

                  <bdo id='KGt5z'></bdo><ul id='KGt5z'></ul>
                  本文介绍了将 MVC 与 libgdx scene2d 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我开始使用 libgdx 开发游戏.这实际上是我的第二次尝试,因为当我开始第一次尝试时,我并不了解 libgdx.在我的第一次尝试中,我有一个带有逻辑和纹理的演员子类.然后我开始阅读 Gustavo Steigerts 教程,我看到他试图将逻辑和视图分开.我尝试做同样的事情,但视图是我的演员子类,包含有关大小和位置的信息,所以它必须进行碰撞检测,这是逻辑的一部分.此外,如果您在 Google 上搜索,您会发现使用 Scene2d 无法执行 MVC.那么有没有办法使用 MVC 实现一个场景 2d 游戏,或者我应该忽略这个模式并在一个扩展 actor 的类中拥有模型和视图?

                  I started developing a game using libgdx. It is actually my second try because when i started the first try i did not know enaught of libgdx. In my first try i had an actor subclass with the logic and the texture in it. Then i started reading Gustavo Steigerts tutorial and i saw that he tryed to separate logic and view. I tryed to do the same, but the view is my actor subclass with informations about size and position, so it has to do the collision detection, which is part of the logic. Also if you search on Google you find that with Scene2d you cannot do the MVC. So is there a way to implement a scene2d game using MVC or should i ignore this patern and have model and view in one class which extends actor?

                  推荐答案

                  这是一个主要基于意见的问题,但在涉及到 scene2d 和 MVC 模式时却经常出现.

                  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.

                  一般来说,像模型-视图-控制器模式那样分离关注点总是有意义的.使用scene2d 这并不容易,因为Actors 已经有一个act() 和一个draw() 方法.

                  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.

                  在我看来,您应该始终尝试像他们一样为您的游戏世界(实体)建模.应该有一个Player,也许是一个Rocket,也许还有一个Bunny类/演员/实体,他们应该知道他们需要知道和管理的一切他们自己.这与实体系统框架相反,实体由部分"组成,而这些部分由外部系统控制.

                  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.

                  大多数情况下,将所有内容放在一起也会使其更加灵活,因为您已经在一个地方拥有了所需的一切.您的游戏玩法可能会改变,您的实体也会如此.如果您发现您的实体太大,您仍然可以将它们分成几个部分,例如 PlayerModelPlayerControllerPlayerRenderer 需要相互引用,然后触发 act()render() 方法中的引用.

                  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.

                  这篇关于将 MVC 与 libgdx scene2d 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:从 libgdx 中的集合中检测触摸对象(移动)的最佳方 下一篇:LIBGDX 加速整个游戏(使用 box2d)

                  相关文章

                  最新文章

                  <i id='amFK6'><tr id='amFK6'><dt id='amFK6'><q id='amFK6'><span id='amFK6'><b id='amFK6'><form id='amFK6'><ins id='amFK6'></ins><ul id='amFK6'></ul><sub id='amFK6'></sub></form><legend id='amFK6'></legend><bdo id='amFK6'><pre id='amFK6'><center id='amFK6'></center></pre></bdo></b><th id='amFK6'></th></span></q></dt></tr></i><div id='amFK6'><tfoot id='amFK6'></tfoot><dl id='amFK6'><fieldset id='amFK6'></fieldset></dl></div>

                  <small id='amFK6'></small><noframes id='amFK6'>

                  • <bdo id='amFK6'></bdo><ul id='amFK6'></ul>

                    1. <legend id='amFK6'><style id='amFK6'><dir id='amFK6'><q id='amFK6'></q></dir></style></legend>

                      <tfoot id='amFK6'></tfoot>