<i id='DZG9q'><tr id='DZG9q'><dt id='DZG9q'><q id='DZG9q'><span id='DZG9q'><b id='DZG9q'><form id='DZG9q'><ins id='DZG9q'></ins><ul id='DZG9q'></ul><sub id='DZG9q'></sub></form><legend id='DZG9q'></legend><bdo id='DZG9q'><pre id='DZG9q'><center id='DZG9q'></center></pre></bdo></b><th id='DZG9q'></th></span></q></dt></tr></i><div id='DZG9q'><tfoot id='DZG9q'></tfoot><dl id='DZG9q'><fieldset id='DZG9q'></fieldset></dl></div>
    1. <legend id='DZG9q'><style id='DZG9q'><dir id='DZG9q'><q id='DZG9q'></q></dir></style></legend>
      <tfoot id='DZG9q'></tfoot>
    2. <small id='DZG9q'></small><noframes id='DZG9q'>

        <bdo id='DZG9q'></bdo><ul id='DZG9q'></ul>

    3. 具有多个小部件的 LibGDX 和 ScrollPane

      时间:2023-05-18

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

          • <bdo id='L5csz'></bdo><ul id='L5csz'></ul>
              <tbody id='L5csz'></tbody>
          • <small id='L5csz'></small><noframes id='L5csz'>

            <legend id='L5csz'><style id='L5csz'><dir id='L5csz'><q id='L5csz'></q></dir></style></legend>
                本文介绍了具有多个小部件的 LibGDX 和 ScrollPane的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                尝试将多个项目添加到滚动窗格中,我很快发现所有addActor"函数都不支持.因此,我添加了一个包含我想要的所有项目的表格(此代码错过了我仍想添加的图像)以制作可滚动的信用屏幕......但这种方法(当前)不允许溢出,渲染ScrollPane 没用.(我的文字只显示到屏幕允许的高度,并且不可滚动).在 LibGDX 中制作具有多个小部件的可滚动窗格的方法是什么?(我目前只关心Android和Win/Lin/Mac平台.

                Trying to add multiple items to a scrollpane I quickly found that all "addActor" functions are Unsupported. So, I went with adding a table with all the items I wanted (this code misses a image that I still want to add) to make a scrollable credits screen... but this approach (currently) doesn't allow for overflow, rendering the ScrollPane useless. (My text is only shown up to what the screen's height allows, and isn't scrollable). What's the way to make a scrollable pane with multiple widgets in LibGDX? (I only care about Android and Win/Lin/Mac platforms at the moment.

                    pane = new ScrollPane(null, skin);
                    pane.setFillParent(true);
                    paneContent = new Table(skin);
                    paneContent.setFillParent(true);
                    Label temp = new Label("", skin);
                    temp.setAlignment(Align.left, Align.center);
                    temp.setText( Gdx.files.internal("licenses/credits.txt").readString("UTF-8") );
                    paneContent.addActor(temp);
                    pane.setWidget(paneContent);
                    stage.addActor(pane);
                

                推荐答案

                如果你想将多个项目放入 ScrollPane 中,你只需要在其中放入一个表格,然后为要放入的每个小部件调用 add()滚动窗格.

                If you want to put multiple items into the ScrollPane you simply need to put a table into it and call add() for each widget you want to put into the ScrollPane.

                以下是如何使您的信用可滚动的示例:

                Below is an example of how to make your credits scrollable:

                public class ScrollTest implements ApplicationListener {
                    private Stage stage;
                
                    private static final String reallyLongString = "This
                Is
                A
                Really
                Long
                String
                That
                Has
                Lots
                Of
                Lines
                And
                Repeats.
                "
                        + "This
                Is
                A
                Really
                Long
                String
                That
                Has
                Lots
                Of
                Lines
                And
                Repeats.
                "
                        + "This
                Is
                A
                Really
                Long
                String
                That
                Has
                Lots
                Of
                Lines
                And
                Repeats.
                ";
                
                    @Override public void create() {
                        this.stage = new Stage();
                        Gdx.input.setInputProcessor(this.stage);
                        final Skin skin = new Skin(Gdx.files.internal("skin/uiskin.json"));
                
                        final Label text = new Label(reallyLongString, skin);
                        text.setAlignment(Align.center);
                        text.setWrap(true);
                        final Label text2 = new Label("This is a short string!", skin);
                        text2.setAlignment(Align.center);
                        text2.setWrap(true);
                        final Label text3 = new Label(reallyLongString, skin);
                        text3.setAlignment(Align.center);
                        text3.setWrap(true);
                
                        final Table scrollTable = new Table();
                        scrollTable.add(text);
                        scrollTable.row();
                        scrollTable.add(text2);
                        scrollTable.row();
                        scrollTable.add(text3);
                
                        final ScrollPane scroller = new ScrollPane(scrollTable);
                
                        final Table table = new Table();
                        table.setFillParent(true);
                        table.add(scroller).fill().expand();
                
                        this.stage.addActor(table);
                    }
                
                    @Override public void render() {
                        this.stage.act();
                        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
                        this.stage.draw();
                    }
                
                    @Override public void resize(final int width, final int height) {}
                    @Override public void pause() {}
                    @Override public void resume() {}
                    @Override public void dispose() {}
                }
                

                添加了在 ScrollPane 中设置表格的代码.

                Added code on setting up a table inside of a ScrollPane.

                这篇关于具有多个小部件的 LibGDX 和 ScrollPane的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:LibGdx 如何使用 OrthographicCamera 滚动? 下一篇:libgdx 中的圆矩形碰撞侧检测

                相关文章

                最新文章

                <tfoot id='GfyZ8'></tfoot>

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

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