【问题标题】:How to put Actors on top of each other?如何将Actor放在彼此之上?
【发布时间】:2018-03-10 11:23:33
【问题描述】:

如何将 Scene2d 演员放在一起?,我正在尝试制作照片库。我将在表格中添加一个图像演员,然后在侧面有用于切换图像的按钮。但是将演员添加到表格是一场噩梦,您无法指定位置,最重要的是您无法将演员添加到另一个演员之上。 Scene2d 中有解决方案吗?

【问题讨论】:

  • 如果你想把两个演员放在同一个地方,你可以使用Stack

标签: java libgdx scene2d


【解决方案1】:

正如评论中提到的,尝试使用来自 Libgdx 的 Stack 类。

简单示例 -

    Table root = new Table();
    Stack stack = new Stack();

    Table imageTable = new Table();
    //do stuff with table.

    Table buttonTable = new Table();
    //do stuff with button table

    stack.add(imageTable);
    stack.add(buttonTable); //button table will be placed exactly above imageTable

    root.add(stack);
    //do whatever you wanna do now with the root like adding on stage.

【讨论】:

    猜你喜欢
    • 2013-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-12
    • 2022-01-21
    • 1970-01-01
    • 1970-01-01
    • 2023-02-07
    相关资源
    最近更新 更多