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

    <tfoot id='nJMDz'></tfoot>

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

    <i id='nJMDz'><tr id='nJMDz'><dt id='nJMDz'><q id='nJMDz'><span id='nJMDz'><b id='nJMDz'><form id='nJMDz'><ins id='nJMDz'></ins><ul id='nJMDz'></ul><sub id='nJMDz'></sub></form><legend id='nJMDz'></legend><bdo id='nJMDz'><pre id='nJMDz'><center id='nJMDz'></center></pre></bdo></b><th id='nJMDz'></th></span></q></dt></tr></i><div id='nJMDz'><tfoot id='nJMDz'></tfoot><dl id='nJMDz'><fieldset id='nJMDz'></fieldset></dl></div>
    1. <legend id='nJMDz'><style id='nJMDz'><dir id='nJMDz'><q id='nJMDz'></q></dir></style></legend>
    2. 什么是配置 libgdx 屏幕的正确位置

      时间:2023-07-28

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

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

                <tfoot id='Vz9w4'></tfoot>
                  <tbody id='Vz9w4'></tbody>

              • <legend id='Vz9w4'><style id='Vz9w4'><dir id='Vz9w4'><q id='Vz9w4'></q></dir></style></legend>
                本文介绍了什么是配置 libgdx 屏幕的正确位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                您好,我正在开发一款游戏,我想知道如何处理资源,因为我遇到了内存问题.

                Hello I am working out a game and I wonder how to dispose resources as I am experiencing memory problems.

                我有这样的事情:

                public SplashScreen implements Screen {
                    @Override
                    public void render(float delta) {
                    }
                    @Override
                    public void dispose() {
                        if (batch != null)
                            batch.dispose();
                        batch = null;
                    }
                }
                
                public MapScreen implements Screen {
                    @Override
                    public void render(float delta) {
                    }
                    @Override
                    public void show() {
                        splashScreenInstance.dispose();
                    }
                    @Override
                    public void dispose() {
                        if (mesh != null)
                        mesh.dispose();
                        mesh = null;
                    }
                }
                

                一旦调用 MapScreen 的 show 方法,我就会处理启动画面.以前我将屏幕设置为 MapScree.仍然调用了 splashScreenInstance 的渲染方法,并且我收到了空指针异常.为什么会这样?

                And I am disposing the splash screen as soon as the show method of MapScreen is called. Previously I'd settled the screen to the MapScree. Still the render method of the splashScreenInstance is called and I'd received null pointer exceptions. Why this is so?

                我希望一旦我设置了另一个屏幕,前一个屏幕将不再呈现.这似乎并非如此.我尝试在使用游戏实例设置屏幕后立即进行处理,在我要处理的屏幕上调用 hide 方法之后,最后在下一个屏幕的 show 方法上进行处理.所有这些情况在渲染当前屏幕之前仍然会渲染前一个屏幕几次.

                I'd expect that once I set another screen, the previous one is no longer rendered. This is not seemingly so. I'd tried disposing right after setting the screen using the game instance, right after the hide method is called on the screen I want to dispose and finally on the show method of the next screen. All of these cases still renders the previous screen a few times before rendering the current one.

                我真的需要恢复内存,而且我不想每次(在渲染方法上)都测试空指针,因为这会降低性能.

                I really need to recover memory and also I don't want to test each time (On the render method) for null pointers as this has performance penalties.

                有什么建议吗?

                谢谢

                推荐答案

                你在哪里调用 setScreen?由于一切都应该在渲染线程(甚至 InputListeners)中发生,您应该能够在您的第一个 Screen 中调用 setScreen,然后从渲染方法返回.Game 实例将在您的第一个 Screen 上自动调用 hide,您可以在此处调用 dispose.

                Where are you calling setScreen? Since everything should be happening in the rendering thread (even InputListeners) you should be able to call setScreen in your first Screen and then return from the render method. The Game instance will automatically call hide on your first Screen which is where you can call dispose.

                这篇关于什么是配置 libgdx 屏幕的正确位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:libgdx 在 Mac 上抛出异常,无法加载共享库 libgdx 下一篇:LibGDX FreeTypeFontGenerator NoSuchField 异常

                相关文章

                最新文章

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

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

                  1. <tfoot id='LpIxd'></tfoot>